We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dfaa392 + 6702ad1 commit 357a798Copy full SHA for 357a798
python/pyspark/sql/dataframe.py
@@ -1725,11 +1725,14 @@ def toPandas(self):
1725
dtype = {}
1726
for field in self.schema:
1727
pandas_type = _to_corrected_pandas_type(field.dataType)
1728
- if (pandas_type):
+ if pandas_type is not None:
1729
dtype[field.name] = pandas_type
1730
1731
- df = pd.DataFrame.from_records(self.collect(), columns=self.columns)
1732
- return df.astype(dtype, copy=False)
+ pdf = pd.DataFrame.from_records(self.collect(), columns=self.columns)
+
1733
+ for f, t in dtype.items():
1734
+ pdf[f] = pdf[f].astype(t, copy=False)
1735
+ return pdf
1736
1737
##########################################################################################
1738
# Pandas compatibility
0 commit comments