Skip to content

Commit e1aeb4a

Browse files
committed
Hacky way to preserve True/False
1 parent a780151 commit e1aeb4a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modin/core/dataframe/pandas/dataframe/dataframe.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4698,8 +4698,6 @@ def to_pandas(self):
46984698
df = self._partition_mgr_cls.to_pandas(self._partitions)
46994699
if df.empty:
47004700
df = pandas.DataFrame(columns=self.columns, index=self.index)
4701-
if len(df.columns) and self.has_materialized_dtypes:
4702-
df = df.astype(self.dtypes)
47034701
else:
47044702
for axis, has_external_index in enumerate(
47054703
["has_materialized_index", "has_materialized_columns"]
@@ -4717,6 +4715,13 @@ def to_pandas(self):
47174715
# into the internal ones
47184716
df = df.set_axis(axis=axis, labels=external_index, copy=False)
47194717

4718+
# Hacky way to coerce the output to the correct type for booleans which might
4719+
# contain NA
4720+
if len(df.columns) and self.has_materialized_dtypes:
4721+
#df = df.astype(self.dtypes)
4722+
for col in self.dtypes.index:
4723+
if df.dtypes[col] != self.dtypes[col] and self.dtypes[col] == np.dtype('bool'):
4724+
df[col] = df[col].replace(1.0, True).replace(0.0, False)
47204725
return df
47214726

47224727
def to_numpy(self, **kwargs):

0 commit comments

Comments
 (0)