@@ -1629,24 +1629,33 @@ def to_arrow_type(dt):
16291629 return arrow_type
16301630
16311631
1632- def _check_dataframe_localize_timestamps (df ):
1633- """ Convert timezone aware timestamps to timezone-naive in local time
1632+ def _check_dataframe_localize_timestamps (pdf ):
1633+ """
1634+ Convert timezone aware timestamps to timezone-naive in local time
1635+
1636+ :param pdf: pandas.DataFrame
1637+ :return pandas.DataFrame where any timezone aware columns have be converted to tz-naive
16341638 """
16351639 from pandas .api .types import is_datetime64tz_dtype
1636- for column , series in df .iteritems ():
1640+ for column , series in pdf .iteritems ():
16371641 # TODO: handle nested timestamps, such as ArrayType(TimestampType())?
16381642 if is_datetime64tz_dtype (series .dtype ):
1639- df [column ] = series .dt .tz_convert ('tzlocal()' ).dt .tz_localize (None )
1640- return df
1643+ pdf [column ] = series .dt .tz_convert ('tzlocal()' ).dt .tz_localize (None )
1644+ return pdf
16411645
16421646
16431647def _check_series_convert_timestamps_internal (s ):
1644- """ Convert a tz-naive timestamp in local tz to UTC normalized for Spark internal storage
16451648 """
1646- from pandas .api .types import is_datetime64_dtype
1649+ Convert a tz-naive timestamp in local tz to UTC normalized for Spark internal storage
1650+ :param s: a pandas.Series
1651+ :return pandas.Series where if it is a timestamp, has been UTC normalized without a time zone
1652+ """
1653+ from pandas .api .types import is_datetime64_dtype , is_datetime64tz_dtype
16471654 # TODO: handle nested timestamps, such as ArrayType(TimestampType())?
16481655 if is_datetime64_dtype (s .dtype ):
16491656 return s .dt .tz_localize ('tzlocal()' ).dt .tz_convert ('UTC' )
1657+ elif is_datetime64tz_dtype (s .dtype ):
1658+ return s .dt .tz_convert ('UTC' )
16501659 else :
16511660 return s
16521661
0 commit comments