diff --git a/modin/pandas/base.py b/modin/pandas/base.py index bac75a18a0b..298a376f972 100644 --- a/modin/pandas/base.py +++ b/modin/pandas/base.py @@ -288,7 +288,9 @@ def _build_repr_df( A pandas dataset with `num_rows` or fewer rows and `num_cols` or fewer columns. """ # Fast track for empty dataframe. - if len(self) == 0 or (self._is_dataframe and self._query_compiler.get_axis_len(1) == 0): + if len(self) == 0 or ( + self._is_dataframe and self._query_compiler.get_axis_len(1) == 0 + ): return pandas.DataFrame( index=self.index, columns=self.columns if self._is_dataframe else None, diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py index 7a2013a1349..ef7899070b8 100644 --- a/modin/pandas/dataframe.py +++ b/modin/pandas/dataframe.py @@ -269,7 +269,9 @@ def __repr__(self) -> str: str """ num_rows = pandas.get_option("display.max_rows") or len(self) - num_cols = pandas.get_option("display.max_columns") or self._query_compiler.get_axis_len(1) + num_cols = pandas.get_option( + "display.max_columns" + ) or self._query_compiler.get_axis_len(1) result = repr(self._build_repr_df(num_rows, num_cols)) if len(self) > num_rows or self._query_compiler.get_axis_len(1) > num_cols: # The split here is so that we don't repr pandas row lengths. @@ -297,9 +299,7 @@ def _repr_html_(self) -> str: # pragma: no cover # We split so that we insert our correct dataframe dimensions. return result.split("
")[ 0 - ] + "
{0} rows x {1} columns
\n".format( - *self.shape - ) + ] + "{0} rows x {1} columns
\n".format(*self.shape) else: return result @@ -781,7 +781,9 @@ def dot(self, other) -> Union[DataFrame, Series]: # noqa: PR01, RT01, D200 """ if isinstance(other, BasePandasDataset): common = self.columns.union(other.index) - if len(common) > self._query_compiler.get_axis_len(1) or len(common) > len(other.index): + if len(common) > self._query_compiler.get_axis_len(1) or len(common) > len( + other.index + ): raise ValueError("Matrices are not aligned") qc = other.reindex(index=common)._query_compiler @@ -1119,7 +1121,11 @@ def insert( ) if allow_duplicates is not True and column in self.columns: raise ValueError(f"cannot insert {column}, already exists") - if not -self._query_compiler.get_axis_len(1) <= loc <= self._query_compiler.get_axis_len(1): + if ( + not -self._query_compiler.get_axis_len(1) + <= loc + <= self._query_compiler.get_axis_len(1) + ): raise IndexError( f"index {loc} is out of bounds for axis 0 with size {self._query_compiler.get_axis_len(1)}" ) @@ -2074,7 +2080,9 @@ def squeeze( Squeeze 1 dimensional axis objects into scalars. """ axis = self._get_axis_number(axis) if axis is not None else None - if axis is None and (self._query_compiler.get_axis_len(1) == 1 or len(self) == 1): + if axis is None and ( + self._query_compiler.get_axis_len(1) == 1 or len(self) == 1 + ): return Series(query_compiler=self._query_compiler).squeeze() if axis == 1 and self._query_compiler.get_axis_len(1) == 1: self._query_compiler._shape_hint = "column" @@ -2680,7 +2688,9 @@ def __setitem__(self, key, value) -> None: self.columns = prev_index.insert(0, key) return # Do new column assignment after error checks and possible value modifications - self.insert(loc=self._query_compiler.get_axis_len(1), column=key, value=value) + self.insert( + loc=self._query_compiler.get_axis_len(1), column=key, value=value + ) return if not hashable(key):