Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _compute_map_reduce_metadata(self, axis, new_parts):
if axis == 0:
columns = self.columns
index = ["__reduced__"]
new_lengths = [1]
new_widths = self._column_widths
new_dtypes = self._dtypes
else:
columns = ["__reduced__"]
index = self.index
new_lengths = self._row_lengths
new_widths = [1]
if self._dtypes is not None:
new_dtypes = pandas.Series(
np.full(1, find_common_type(self.dtypes.values)),
index=["__reduced__"],
)
else:
new_dtypes = self._dtypes
return self.__constructor__(
new_parts, index, columns, new_lengths, new_widths, new_dtypes
)
return df.apply(lambda col: find_common_type(col.values), axis=0)
.apply(lambda row: find_common_type(row.values), axis=1)
.squeeze(axis=0)
.apply(lambda row: find_common_type(row.values), axis=1)
.squeeze(axis=0)
def transpose(self):
"""Transpose the index and columns of this dataframe.
Returns:
A new dataframe.
"""
new_partitions = self._frame_mgr_cls.lazy_map_partitions(
self._partitions, lambda df: df.T
).T
new_dtypes = pandas.Series(
np.full(len(self.index), find_common_type(self.dtypes.values)),
index=self.index,
)
return self.__constructor__(
new_partitions,
self.columns,
self.index,
self._column_widths,
self._row_lengths,
dtypes=new_dtypes,
)