Skip to content

Commit b709d78

Browse files
committed
TimestampType is correctly inferred as datetime64[ns]
1 parent 78119ca commit b709d78

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/pyspark/sql/dataframe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,7 @@ def _to_corrected_pandas_type(dt):
17931793
"""
17941794
When converting Spark SQL records to Pandas DataFrame, the inferred data type may be wrong.
17951795
This method gets the corrected data type for Pandas if that type may be inferred uncorrectly.
1796+
NOTE: DateType is inferred incorrectly as 'object', TimestampType is correct with datetime64[ns]
17961797
"""
17971798
import numpy as np
17981799
if type(dt) == ByteType:
@@ -1803,7 +1804,7 @@ def _to_corrected_pandas_type(dt):
18031804
return np.int32
18041805
elif type(dt) == FloatType:
18051806
return np.float32
1806-
elif type(dt) == DateType or type(dt) == TimestampType:
1807+
elif type(dt) == DateType:
18071808
return 'datetime64[ns]'
18081809
else:
18091810
return None

0 commit comments

Comments
 (0)