From 46bf318fb031f48555ee78cc81a478c8d326d2d3 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Wed, 9 Dec 2020 12:27:35 -0500 Subject: [PATCH 01/21] typing --- pandas/core/frame.py | 122 +++++++++++++++++++++++++++---------------- 1 file changed, 78 insertions(+), 44 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index fd7820196f9a9..819cf4fc60aff 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -22,12 +22,14 @@ TYPE_CHECKING, Any, AnyStr, + Callable, Dict, FrozenSet, Hashable, Iterable, Iterator, List, + Mapping, Optional, Sequence, Set, @@ -48,6 +50,7 @@ from pandas._libs.lib import no_default from pandas._typing import ( AggFuncType, + AnyArrayLike, ArrayLike, Axes, Axis, @@ -59,6 +62,8 @@ Label, Level, Renamer, + Scalar, + Shape, StorageOptions, ValueKeyFunc, ) @@ -643,7 +648,7 @@ def axes(self) -> List[Index]: return [self.index, self.columns] @property - def shape(self) -> Tuple[int, int]: + def shape(self) -> Shape: """ Return a tuple representing the dimensionality of the DataFrame. @@ -1071,7 +1076,9 @@ def iterrows(self) -> Iterable[Tuple[Label, Series]]: s = klass(v, index=columns, name=k) yield k, s - def itertuples(self, index: bool = True, name: Optional[str] = "Pandas"): + def itertuples( + self, index: bool = True, name: Optional[str] = "Pandas" + ) -> Iterable[Tuple]: """ Iterate over DataFrame rows as namedtuples. @@ -1161,7 +1168,7 @@ def __len__(self) -> int: """ return len(self.index) - def dot(self, other): + def dot(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: """ Compute the matrix multiplication between the DataFrame and other. @@ -1271,13 +1278,13 @@ def dot(self, other): else: # pragma: no cover raise TypeError(f"unsupported type: {type(other)}") - def __matmul__(self, other): + def __matmul__(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ return self.dot(other) - def __rmatmul__(self, other): + def __rmatmul__(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ @@ -1294,7 +1301,13 @@ def __rmatmul__(self, other): # IO methods (to / from other formats) @classmethod - def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> DataFrame: + def from_dict( + cls, + data, + orient: str = "columns", + dtype: Optional[Dtype] = None, + columns: Optional[List] = None, + ) -> DataFrame: """ Construct DataFrame from dict of array-like or dicts. @@ -1373,7 +1386,10 @@ def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> DataFram return cls(data, index=index, columns=columns, dtype=dtype) def to_numpy( - self, dtype=None, copy: bool = False, na_value=lib.no_default + self, + dtype: Optional[Dtype] = None, + copy: bool = False, + na_value: Scalar = lib.no_default, ) -> np.ndarray: """ Convert the DataFrame to a NumPy array. @@ -1440,7 +1456,7 @@ def to_numpy( return result - def to_dict(self, orient="dict", into=dict): + def to_dict(self, orient: str = "dict", into=dict) -> Union[Dict, List, Mapping]: """ Convert the DataFrame to a dictionary. @@ -1615,15 +1631,15 @@ def to_dict(self, orient="dict", into=dict): def to_gbq( self, - destination_table, - project_id=None, - chunksize=None, - reauth=False, - if_exists="fail", - auth_local_webserver=False, - table_schema=None, - location=None, - progress_bar=True, + destination_table: str, + project_id: Optional[str] = None, + chunksize: Optional[int] = None, + reauth: bool = False, + if_exists: str = "fail", + auth_local_webserver: bool = False, + table_schema: Optional[List[Dict]] = None, + location: Optional[str] = None, + progress_bar: bool = True, credentials=None, ) -> None: """ @@ -2478,25 +2494,25 @@ def to_html( buf=None, columns=None, col_space=None, - header=True, - index=True, + header: bool = True, + index: bool = True, na_rep="NaN", formatters=None, float_format=None, sparsify=None, - index_names=True, + index_names: bool = True, justify=None, max_rows=None, max_cols=None, - show_dimensions=False, + show_dimensions: bool = False, decimal=".", - bold_rows=True, + bold_rows: bool = True, classes=None, - escape=True, - notebook=False, - border=None, - table_id=None, - render_links=False, + escape: bool = True, + notebook: bool = False, + border: Optional[int] = None, + table_id: Optional[str] = None, + render_links: bool = False, encoding=None, ): """ @@ -2708,7 +2724,7 @@ def info( show_counts=show_counts, ) - def memory_usage(self, index=True, deep=False) -> Series: + def memory_usage(self, index: bool = True, deep: bool = False) -> Series: """ Return the memory usage of each column in bytes. @@ -2931,7 +2947,7 @@ def T(self) -> DataFrame: # ---------------------------------------------------------------------- # Indexing Methods - def _ixs(self, i: int, axis: int = 0): + def _ixs(self, i: int, axis: Axis = 0): """ Parameters ---------- @@ -3108,7 +3124,7 @@ def _getitem_multilevel(self, key): # loc is neither a slice nor ndarray, so must be an int return self._ixs(loc, axis=1) - def _get_value(self, index, col, takeable: bool = False): + def _get_value(self, index, col, takeable: bool = False) -> Scalar: """ Quickly retrieve single value at passed column and index. @@ -3224,7 +3240,7 @@ def _iset_item(self, loc: int, value): if len(self): self._check_setitem_copy() - def _set_item(self, key, value): + def _set_item(self, key, value) -> None: """ Add series to DataFrame in specified column. @@ -3243,7 +3259,7 @@ def _set_item(self, key, value): if len(self): self._check_setitem_copy() - def _set_value(self, index, col, value, takeable: bool = False): + def _set_value(self, index, col, value: Scalar, takeable: bool = False) -> None: """ Put single value at passed column and index. @@ -3276,7 +3292,7 @@ def _set_value(self, index, col, value, takeable: bool = False): self.loc[index, col] = value self._item_cache.pop(col, None) - def _ensure_valid_index(self, value): + def _ensure_valid_index(self, value) -> None: """ Ensure that if we don't have an index, that we can create one from the passed value. @@ -3311,7 +3327,7 @@ def _box_col_values(self, values, loc: int) -> Series: # ---------------------------------------------------------------------- # Unsorted - def query(self, expr, inplace=False, **kwargs): + def query(self, expr: str, inplace: bool = False, **kwargs) -> Optional[DataFrame]: """ Query the columns of a DataFrame with a boolean expression. @@ -3472,10 +3488,13 @@ def query(self, expr, inplace=False, **kwargs): if inplace: self._update_inplace(result) + return None else: return result - def eval(self, expr, inplace=False, **kwargs): + def eval( + self, expr: str, inplace: bool = False, **kwargs + ) -> Optional[Union[AnyArrayLike, Scalar]]: """ Evaluate a string describing operations on DataFrame columns. @@ -3732,7 +3751,7 @@ def extract_unique_dtypes_from_dtypes_set( return self.iloc[:, keep_these.values] - def insert(self, loc, column, value, allow_duplicates=False) -> None: + def insert(self, loc: int, column, value, allow_duplicates: bool = False) -> None: """ Insert column into DataFrame at specified location. @@ -3846,7 +3865,7 @@ def assign(self, **kwargs) -> DataFrame: data[k] = com.apply_if_callable(v, data) return data - def _sanitize_column(self, key, value, broadcast=True): + def _sanitize_column(self, key, value, broadcast: bool = True) -> np.ndarray: """ Ensures new columns (which go into the BlockManager as new blocks) are always copied and converted into an array. @@ -3954,7 +3973,7 @@ def reindexer(value): return np.atleast_2d(np.asarray(value)) @property - def _series(self): + def _series(self) -> "Dict[int, Series]": return { item: Series( self._mgr.iget(idx), index=self.index, name=item, fastpath=True @@ -3962,7 +3981,9 @@ def _series(self): for idx, item in enumerate(self.columns) } - def lookup(self, row_labels, col_labels) -> np.ndarray: + def lookup( + self, row_labels: Sequence[Label], col_labels: Sequence[Label] + ) -> np.ndarray: """ Label-based "fancy indexing" function for DataFrame. Given equal-length arrays of row and column labels, return an @@ -4109,7 +4130,7 @@ def align( join="outer", axis=None, level=None, - copy=True, + copy: bool = True, fill_value=None, method=None, limit=None, @@ -5912,7 +5933,9 @@ def nsmallest(self, n, columns, keep="first") -> DataFrame: self, n=n, keep=keep, columns=columns ).nsmallest() - def swaplevel(self, i=-2, j=-1, axis=0) -> DataFrame: + def swaplevel( + self, i: Union[int, str] = -2, j: Union[int, str] = -1, axis: Axis = 0 + ) -> DataFrame: """ Swap levels i and j in a MultiIndex on a particular axis. @@ -5943,7 +5966,9 @@ def swaplevel(self, i=-2, j=-1, axis=0) -> DataFrame: result.columns = result.columns.swaplevel(i, j) return result - def reorder_levels(self, order, axis=0) -> DataFrame: + def reorder_levels( + self, order: Union[List[int], List[str]], axis: Axis = 0 + ) -> DataFrame: """ Rearrange index levels using input order. May not drop or duplicate levels. @@ -6234,7 +6259,11 @@ def compare( ) def combine( - self, other: DataFrame, func, fill_value=None, overwrite=True + self, + other: DataFrame, + func: Callable, + fill_value: Optional[Scalar] = None, + overwrite: bool = True, ) -> DataFrame: """ Perform column-wise combine with another DataFrame. @@ -6462,7 +6491,12 @@ def combiner(x, y): return self.combine(other, combiner, overwrite=False) def update( - self, other, join="left", overwrite=True, filter_func=None, errors="ignore" + self, + other, + join: str = "left", + overwrite: bool = True, + filter_func: Optional[Callable] = None, + errors: str = "ignore", ) -> None: """ Modify in place using non-NA values from another DataFrame. From eba7251938e8bbfd244586608cc487a4d45d926a Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 11 Dec 2020 15:54:37 -0500 Subject: [PATCH 02/21] typing --- pandas/core/frame.py | 68 ++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 819cf4fc60aff..4dfdd8bf29e2a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6023,7 +6023,7 @@ def _arith_method(self, other, op): _logical_method = _arith_method - def _dispatch_frame_op(self, right, func, axis: Optional[int] = None): + def _dispatch_frame_op(self, right, func: Callable, axis: Optional[int] = None): """ Evaluate the frame operation func(left, right) by evaluating column-by-column, dispatching to the Series implementation. @@ -6104,7 +6104,7 @@ def _arith_op(left, right): new_data = self._dispatch_frame_op(other, _arith_op) return new_data - def _construct_result(self, result) -> DataFrame: + def _construct_result(self, result: DataFrame) -> DataFrame: """ Wrap the result of an arithmetic, comparison, or logical operation. @@ -6735,8 +6735,8 @@ def update( def groupby( self, by=None, - axis=0, - level=None, + axis: int = 0, + level: Optional[Level] = None, as_index: bool = True, sort: bool = True, group_keys: bool = True, @@ -7067,12 +7067,12 @@ def pivot_table( values=None, index=None, columns=None, - aggfunc="mean", + aggfunc: AggFuncType = "mean", fill_value=None, - margins=False, - dropna=True, + margins: bool = False, + dropna: bool = True, margins_name="All", - observed=False, + observed: bool = False, ) -> DataFrame: from pandas.core.reshape.pivot import pivot_table @@ -7089,7 +7089,7 @@ def pivot_table( observed=observed, ) - def stack(self, level=-1, dropna=True): + def stack(self, level: Union[int, str, List] = -1, dropna: bool = True): """ Stack the prescribed level(s) from columns to index. @@ -7338,7 +7338,7 @@ def explode( return result - def unstack(self, level=-1, fill_value=None): + def unstack(self, level: Level = -1, fill_value=None): """ Pivot a level of the (necessarily hierarchical) index labels. @@ -7409,7 +7409,7 @@ def melt( var_name=None, value_name="value", col_level=None, - ignore_index=True, + ignore_index: bool = True, ) -> DataFrame: return melt( @@ -7670,7 +7670,15 @@ def transform( assert isinstance(result, DataFrame) return result - def apply(self, func, axis=0, raw=False, result_type=None, args=(), **kwds): + def apply( + self, + func: Callable, + axis: Axis = 0, + raw: bool = False, + result_type: Optional[str] = None, + args: Tuple = (), + **kwds, + ): """ Apply a function along an axis of the DataFrame. @@ -7815,7 +7823,7 @@ def apply(self, func, axis=0, raw=False, result_type=None, args=(), **kwds): ) return op.get_result() - def applymap(self, func, na_action: Optional[str] = None) -> DataFrame: + def applymap(self, func: Callable, na_action: Optional[str] = None) -> DataFrame: """ Apply a function to a Dataframe elementwise. @@ -7895,7 +7903,11 @@ def infer(x): # Merging / joining methods def append( - self, other, ignore_index=False, verify_integrity=False, sort=False + self, + other, + ignore_index: bool = False, + verify_integrity: bool = False, + sort: bool = False, ) -> DataFrame: """ Append rows of `other` to the end of caller, returning a new object. @@ -8036,7 +8048,13 @@ def append( ).__finalize__(self, method="append") def join( - self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False + self, + other, + on=None, + how: str = "left", + lsuffix: str = "", + rsuffix: str = "", + sort: bool = False, ) -> DataFrame: """ Join columns of another DataFrame. @@ -8160,7 +8178,13 @@ def join( ) def _join_compat( - self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False + self, + other, + on=None, + how: str = "left", + lsuffix: str = "", + rsuffix: str = "", + sort: bool = False, ): from pandas.core.reshape.concat import concat from pandas.core.reshape.merge import merge @@ -8226,16 +8250,16 @@ def _join_compat( def merge( self, right, - how="inner", + how: str = "inner", on=None, left_on=None, right_on=None, - left_index=False, - right_index=False, - sort=False, + left_index: bool = False, + right_index: bool = False, + sort: bool = False, suffixes=("_x", "_y"), - copy=True, - indicator=False, + copy: bool = True, + indicator: bool = False, validate=None, ) -> DataFrame: from pandas.core.reshape.merge import merge From 1a452677044f28448ffef60b143b94a83a05bfd8 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 11 Dec 2020 16:27:44 -0500 Subject: [PATCH 03/21] typing --- pandas/core/frame.py | 79 ++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 4dfdd8bf29e2a..ef31bef9f01b9 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -59,6 +59,7 @@ FilePathOrBuffer, FrameOrSeriesUnion, IndexKeyFunc, + IndexLabel, Label, Level, Renamer, @@ -1744,8 +1745,8 @@ def from_records( index=None, exclude=None, columns=None, - coerce_float=False, - nrows=None, + coerce_float: bool = False, + nrows: Optional[bool] = None, ) -> DataFrame: """ Convert structured or record ndarray to DataFrame. @@ -3259,7 +3260,9 @@ def _set_item(self, key, value) -> None: if len(self): self._check_setitem_copy() - def _set_value(self, index, col, value: Scalar, takeable: bool = False) -> None: + def _set_value( + self, index: int, col, value: Scalar, takeable: bool = False + ) -> None: """ Put single value at passed column and index. @@ -4216,12 +4219,12 @@ def reindex(self, *args, **kwargs) -> DataFrame: def drop( self, labels=None, - axis=0, - index=None, + axis: Axis = 0, + index: IndexLabel = None, columns=None, - level=None, - inplace=False, - errors="raise", + level: Level = None, + inplace: bool = False, + errors: str = "raise", ): """ Drop specified labels from rows or columns. @@ -5515,8 +5518,8 @@ def sort_values( # type: ignore[override] def sort_index( self, - axis=0, - level=None, + axis: Axis = 0, + level: Level = None, ascending: bool = True, inplace: bool = False, kind: str = "quicksort", @@ -7070,7 +7073,7 @@ def pivot_table( aggfunc: AggFuncType = "mean", fill_value=None, margins: bool = False, - dropna: bool = True, + dropna=True, margins_name="All", observed: bool = False, ) -> DataFrame: @@ -7089,7 +7092,7 @@ def pivot_table( observed=observed, ) - def stack(self, level: Union[int, str, List] = -1, dropna: bool = True): + def stack(self, level: Level = -1, dropna: bool = True): """ Stack the prescribed level(s) from columns to index. @@ -7616,7 +7619,7 @@ def _gotitem( see_also=_agg_summary_and_see_also_doc, examples=_agg_examples_doc, ) - def aggregate(self, func=None, axis=0, *args, **kwargs): + def aggregate(self, func=None, axis: Axis = 0, *args, **kwargs): axis = self._get_axis_number(axis) relabeling, func, columns, order = reconstruct_func(func, **kwargs) @@ -8260,7 +8263,7 @@ def merge( suffixes=("_x", "_y"), copy: bool = True, indicator: bool = False, - validate=None, + validate: Optional[str] = None, ) -> DataFrame: from pandas.core.reshape.merge import merge @@ -8280,7 +8283,9 @@ def merge( validate=validate, ) - def round(self, decimals=0, *args, **kwargs) -> DataFrame: + def round( + self, decimals: Union[int, Dict, Series] = 0, *args, **kwargs + ) -> DataFrame: """ Round a DataFrame to a variable number of decimal places. @@ -8394,7 +8399,9 @@ def _series_round(s, decimals): # ---------------------------------------------------------------------- # Statistical methods, etc. - def corr(self, method="pearson", min_periods=1) -> DataFrame: + def corr( + self, method: Union[str, Callable] = "pearson", min_periods: int = 1 + ) -> DataFrame: """ Compute pairwise correlation of columns, excluding NA/null values. @@ -8601,7 +8608,13 @@ def cov( return self._constructor(base_cov, index=idx, columns=cols) - def corrwith(self, other, axis=0, drop=False, method="pearson") -> Series: + def corrwith( + self, + other: FrameOrSeriesUnion, + axis: Axis = 0, + drop: bool = False, + method: Union[str, Callable] = "pearson", + ) -> Series: """ Compute pairwise correlation. @@ -8851,9 +8864,9 @@ def _reduce( op, name: str, *, - axis=0, - skipna=True, - numeric_only=None, + axis: Axis = 0, + skipna: bool = True, + numeric_only: Optional[bool] = None, filter_type=None, **kwds, ): @@ -8959,7 +8972,7 @@ def _get_data() -> DataFrame: result = self._constructor_sliced(result, index=labels) return result - def nunique(self, axis=0, dropna=True) -> Series: + def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series: """ Count distinct observations over requested axis. @@ -8999,7 +9012,7 @@ def nunique(self, axis=0, dropna=True) -> Series: """ return self.apply(Series.nunique, axis=axis, dropna=dropna) - def idxmin(self, axis=0, skipna=True) -> Series: + def idxmin(self, axis: Axis = 0, skipna: bool = True) -> Series: """ Return index of first occurrence of minimum over requested axis. @@ -9076,7 +9089,7 @@ def idxmin(self, axis=0, skipna=True) -> Series: result = [index[i] if i >= 0 else np.nan for i in indices] return self._constructor_sliced(result, index=self._get_agg_axis(axis)) - def idxmax(self, axis=0, skipna=True) -> Series: + def idxmax(self, axis: Axis = 0, skipna: bool = True) -> Series: """ Return index of first occurrence of maximum over requested axis. @@ -9164,7 +9177,9 @@ def _get_agg_axis(self, axis_num: int) -> Index: else: raise ValueError(f"Axis must be 0 or 1 (got {repr(axis_num)})") - def mode(self, axis=0, numeric_only=False, dropna=True) -> DataFrame: + def mode( + self, axis: Axis = 0, numeric_only: bool = False, dropna: bool = True + ) -> DataFrame: """ Get the mode(s) of each element along the selected axis. @@ -9251,7 +9266,9 @@ def f(s): return data.apply(f, axis=axis) - def quantile(self, q=0.5, axis=0, numeric_only=True, interpolation="linear"): + def quantile( + self, q=0.5, axis: Axis = 0, numeric_only: bool = True, interpolation="linear" + ) -> FrameOrSeriesUnion: """ Return values at the given quantile over requested axis. @@ -9348,7 +9365,11 @@ def quantile(self, q=0.5, axis=0, numeric_only=True, interpolation="linear"): return result def to_timestamp( - self, freq=None, how: str = "start", axis: Axis = 0, copy: bool = True + self, + freq: Optional[str] = None, + how: str = "start", + axis: Axis = 0, + copy: bool = True, ) -> DataFrame: """ Cast to DatetimeIndex of timestamps, at *beginning* of period. @@ -9381,7 +9402,9 @@ def to_timestamp( setattr(new_obj, axis_name, new_ax) return new_obj - def to_period(self, freq=None, axis: Axis = 0, copy: bool = True) -> DataFrame: + def to_period( + self, freq: Optional[str] = None, axis: Axis = 0, copy: bool = True + ) -> DataFrame: """ Convert DataFrame from DatetimeIndex to PeriodIndex. @@ -9413,7 +9436,7 @@ def to_period(self, freq=None, axis: Axis = 0, copy: bool = True) -> DataFrame: setattr(new_obj, axis_name, new_ax) return new_obj - def isin(self, values) -> DataFrame: + def isin(self, values: Union[FrameOrSeriesUnion, Dict, Iterable]) -> DataFrame: """ Whether each element in the DataFrame is contained in values. From f5cb185b565766a5192724f9310613f1dfd1beda Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 11 Dec 2020 16:36:15 -0500 Subject: [PATCH 04/21] typing --- pandas/core/reshape/pivot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 40496a5b8671b..7aa4bcf6fad62 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -612,7 +612,7 @@ def crosstab( margins=margins, margins_name=margins_name, dropna=dropna, - **kwargs, + **kwargs, # type: ignore[arg-type] ) # GH18321, after pivoting, an extra top level of column index of `__dummy__` is From 4c9b7644a90ad1799ace742e84c32979997bcaec Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 11 Dec 2020 17:02:57 -0500 Subject: [PATCH 05/21] review comments --- pandas/core/frame.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ef31bef9f01b9..8b9727939df0b 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -64,7 +64,6 @@ Level, Renamer, Scalar, - Shape, StorageOptions, ValueKeyFunc, ) @@ -649,7 +648,7 @@ def axes(self) -> List[Index]: return [self.index, self.columns] @property - def shape(self) -> Shape: + def shape(self) -> Tuple[int, int]: """ Return a tuple representing the dimensionality of the DataFrame. @@ -4091,7 +4090,7 @@ def _reindex_columns( new_columns, method, copy, - level, + level: Level, fill_value=None, limit=None, tolerance=None, @@ -4130,15 +4129,15 @@ def _reindex_multi(self, axes, copy, fill_value) -> DataFrame: def align( self, other, - join="outer", - axis=None, - level=None, + join: str = "outer", + axis: Optional[Axis] = None, + level: Optional[Level] = None, copy: bool = True, fill_value=None, - method=None, - limit=None, - fill_axis=0, - broadcast_axis=None, + method: Optional[str] = None, + limit: Optional[int] = None, + fill_axis: Axis = 0, + broadcast_axis: Optional[Axis] = None, ) -> DataFrame: return super().align( other, @@ -4494,10 +4493,10 @@ def rename( def fillna( self, value=None, - method=None, - axis=None, - inplace=False, - limit=None, + method: Optional[str] = None, + axis: Optional[Axis] = None, + inplace: bool = False, + limit: Optional[int] = None, downcast=None, ) -> Optional[DataFrame]: return super().fillna( @@ -4557,9 +4556,9 @@ def replace( self, to_replace=None, value=None, - inplace=False, + inplace: bool = False, limit=None, - regex=False, + regex: bool = False, method="pad", ): return super().replace( @@ -4608,7 +4607,7 @@ def _replace_columnwise( @doc(NDFrame.shift, klass=_shared_doc_kwargs["klass"]) def shift( - self, periods=1, freq=None, axis=0, fill_value=lib.no_default + self, periods: int = 1, freq=None, axis: Axis = 0, fill_value=lib.no_default ) -> DataFrame: axis = self._get_axis_number(axis) @@ -4640,7 +4639,12 @@ def shift( ) def set_index( - self, keys, drop=True, append=False, inplace=False, verify_integrity=False + self, + keys, + drop: bool = True, + append: bool = False, + inplace: bool = False, + verify_integrity: bool = False, ): """ Set the DataFrame index using existing columns. From a273e5c91b6d7ddcf1b4e2e7d4bb2bd1e60f5919 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Sun, 13 Dec 2020 00:53:40 -0500 Subject: [PATCH 06/21] review comment --- pandas/core/frame.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8b9727939df0b..733fe18b3b4ee 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1168,7 +1168,7 @@ def __len__(self) -> int: """ return len(self.index) - def dot(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: + def dot(self, other: Union[AnyArrayLike, FrameOrSeriesUnion]) -> FrameOrSeriesUnion: """ Compute the matrix multiplication between the DataFrame and other. @@ -1278,13 +1278,17 @@ def dot(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: else: # pragma: no cover raise TypeError(f"unsupported type: {type(other)}") - def __matmul__(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: + def __matmul__( + self, other: Union[AnyArrayLike, FrameOrSeriesUnion] + ) -> FrameOrSeriesUnion: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ return self.dot(other) - def __rmatmul__(self, other: Union[AnyArrayLike, DataFrame]) -> FrameOrSeriesUnion: + def __rmatmul__( + self, other: Union[AnyArrayLike, FrameOrSeriesUnion] + ) -> FrameOrSeriesUnion: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ From e0558c53325143e5d41c686e1c33d825b96459a9 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Sun, 13 Dec 2020 01:00:57 -0500 Subject: [PATCH 07/21] review comment --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 733fe18b3b4ee..8ded800e67234 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1310,7 +1310,7 @@ def from_dict( data, orient: str = "columns", dtype: Optional[Dtype] = None, - columns: Optional[List] = None, + columns: Optional[List[Label]] = None, ) -> DataFrame: """ Construct DataFrame from dict of array-like or dicts. From 617e2284f56cb98a090be35a4de9d3b2e1df3caf Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 14 Dec 2020 12:57:14 -0500 Subject: [PATCH 08/21] revert hints to pivot_table --- pandas/core/frame.py | 6 +++--- pandas/core/reshape/pivot.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6aa755ac8ecc2..db3dab385782f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7092,12 +7092,12 @@ def pivot_table( values=None, index=None, columns=None, - aggfunc: AggFuncType = "mean", + aggfunc="mean", fill_value=None, - margins: bool = False, + margins=False, dropna=True, margins_name="All", - observed: bool = False, + observed=False, ) -> DataFrame: from pandas.core.reshape.pivot import pivot_table diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 7aa4bcf6fad62..40496a5b8671b 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -612,7 +612,7 @@ def crosstab( margins=margins, margins_name=margins_name, dropna=dropna, - **kwargs, # type: ignore[arg-type] + **kwargs, ) # GH18321, after pivoting, an extra top level of column index of `__dummy__` is From 9a4d187fd0a5a1d175e97d1cff6d13ea61cb2558 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 14 Dec 2020 13:56:47 -0500 Subject: [PATCH 09/21] take out merge --- pandas/core/frame.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index db3dab385782f..f7d4bc4024614 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8200,10 +8200,10 @@ def _join_compat( self, other, on=None, - how: str = "left", - lsuffix: str = "", - rsuffix: str = "", - sort: bool = False, + how="left", + lsuffix="", + rsuffix="", + sort=False, ): from pandas.core.reshape.concat import concat from pandas.core.reshape.merge import merge @@ -8269,17 +8269,17 @@ def _join_compat( def merge( self, right, - how: str = "inner", + how="inner", on=None, left_on=None, right_on=None, - left_index: bool = False, - right_index: bool = False, - sort: bool = False, + left_index=False, + right_index=False, + sort=False, suffixes=("_x", "_y"), - copy: bool = True, - indicator: bool = False, - validate: Optional[str] = None, + copy=True, + indicator=False, + validate=None, ) -> DataFrame: from pandas.core.reshape.merge import merge From 77e11425bd652bc7a3c108304ff5f487eab0ca58 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 14 Dec 2020 14:02:24 -0500 Subject: [PATCH 10/21] minimize diff --- pandas/core/frame.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f7d4bc4024614..b2376244fb446 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8197,13 +8197,7 @@ def join( ) def _join_compat( - self, - other, - on=None, - how="left", - lsuffix="", - rsuffix="", - sort=False, + self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False ): from pandas.core.reshape.concat import concat from pandas.core.reshape.merge import merge From 2352e454270a9cdf75c73b5e2857012b2cbc42b0 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 14 Dec 2020 14:16:28 -0500 Subject: [PATCH 11/21] fix eval return type annotation --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b2376244fb446..df67321d07907 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3512,7 +3512,7 @@ def query(self, expr: str, inplace: bool = False, **kwargs) -> Optional[DataFram def eval( self, expr: str, inplace: bool = False, **kwargs - ) -> Optional[Union[AnyArrayLike, Scalar]]: + ) -> Optional[Union[AnyArrayLike, DataFrame, Scalar]]: """ Evaluate a string describing operations on DataFrame columns. From 1c942fd109f4a57173660ca671f8c7580f8e8e19 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 14 Dec 2020 20:43:34 -0500 Subject: [PATCH 12/21] review comments --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 27d513a64023f..913fcf9c9e6f0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1457,7 +1457,7 @@ def to_numpy( return result - def to_dict(self, orient: str = "dict", into=dict) -> Union[Dict, List, Mapping]: + def to_dict(self, orient: str = "dict", into=dict) -> Union[List, Mapping]: """ Convert the DataFrame to a dictionary. @@ -3970,7 +3970,7 @@ def _sanitize_column(self, value): return value @property - def _series(self) -> "Dict[int, Series]": + def _series(self) -> Dict[int, Series]: return { item: Series( self._mgr.iget(idx), index=self.index, name=item, fastpath=True From 11247d9fc3354d7f8d1fbf516573fc851935fbbd Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 21 Dec 2020 13:41:15 -0500 Subject: [PATCH 13/21] review comments --- pandas/core/frame.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 913fcf9c9e6f0..cb6f883b75c02 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3378,7 +3378,7 @@ def _box_col_values(self, values, loc: int) -> Series: # ---------------------------------------------------------------------- # Unsorted - def query(self, expr: str, inplace: bool = False, **kwargs) -> Optional[DataFrame]: + def query(self, expr: str, inplace: bool = False, **kwargs): """ Query the columns of a DataFrame with a boolean expression. @@ -3543,9 +3543,7 @@ def query(self, expr: str, inplace: bool = False, **kwargs) -> Optional[DataFram else: return result - def eval( - self, expr: str, inplace: bool = False, **kwargs - ) -> Optional[Union[AnyArrayLike, DataFrame, Scalar]]: + def eval(self, expr: str, inplace: bool = False, **kwargs): """ Evaluate a string describing operations on DataFrame columns. @@ -6119,7 +6117,7 @@ def _arith_op(left, right): new_data = self._dispatch_frame_op(other, _arith_op) return new_data - def _construct_result(self, result: DataFrame) -> DataFrame: + def _construct_result(self, result): """ Wrap the result of an arithmetic, comparison, or logical operation. From 168cad26dbee00fb9670b8e9304d6c826378097a Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 4 Jan 2021 19:00:33 -0500 Subject: [PATCH 14/21] review comments --- pandas/core/frame.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 94b56036bc67d..8cd15fbd5c9be 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -50,7 +50,6 @@ from pandas._libs.lib import no_default from pandas._typing import ( AggFuncType, - AnyArrayLike, ArrayLike, Axes, Axis, @@ -1073,7 +1072,7 @@ def iterrows(self) -> Iterable[Tuple[Label, Series]]: def itertuples( self, index: bool = True, name: Optional[str] = "Pandas" - ) -> Iterable[Tuple]: + ) -> Iterable[Tuple[Any, ...]]: """ Iterate over DataFrame rows as namedtuples. @@ -1163,7 +1162,7 @@ def __len__(self) -> int: """ return len(self.index) - def dot(self, other: Union[AnyArrayLike, FrameOrSeriesUnion]) -> FrameOrSeriesUnion: + def dot(self, other): """ Compute the matrix multiplication between the DataFrame and other. @@ -1273,17 +1272,13 @@ def dot(self, other: Union[AnyArrayLike, FrameOrSeriesUnion]) -> FrameOrSeriesUn else: # pragma: no cover raise TypeError(f"unsupported type: {type(other)}") - def __matmul__( - self, other: Union[AnyArrayLike, FrameOrSeriesUnion] - ) -> FrameOrSeriesUnion: + def __matmul__(self, other): """ Matrix multiplication using binary `@` operator in Python>=3.5. """ return self.dot(other) - def __rmatmul__( - self, other: Union[AnyArrayLike, FrameOrSeriesUnion] - ) -> FrameOrSeriesUnion: + def __rmatmul__(self, other): """ Matrix multiplication using binary `@` operator in Python>=3.5. """ From 6c876ffa2ba41da95f4f38df6a80cbaa7aaae3a8 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 4 Jan 2021 19:27:02 -0500 Subject: [PATCH 15/21] review comments --- pandas/core/frame.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 9fe256a377a59..f6636104c9af8 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -64,6 +64,7 @@ IndexLabel, Label, Level, + NpDtype, PythonFuncType, Renamer, Scalar, @@ -1365,7 +1366,7 @@ def from_dict( def to_numpy( self, - dtype: Optional[Dtype] = None, + dtype: Optional[NpDtype] = None, copy: bool = False, na_value: Scalar = lib.no_default, ) -> np.ndarray: @@ -1723,7 +1724,7 @@ def from_records( exclude=None, columns=None, coerce_float: bool = False, - nrows: Optional[bool] = None, + nrows: Optional[int] = None, ) -> DataFrame: """ Convert structured or record ndarray to DataFrame. @@ -2706,7 +2707,7 @@ def info( show_counts=show_counts, ) - def memory_usage(self, index: bool = True, deep: bool = False) -> Series: + def memory_usage(self, index: bool = True, deep: bool = False): """ Return the memory usage of each column in bytes. @@ -2929,7 +2930,7 @@ def T(self) -> DataFrame: # ---------------------------------------------------------------------- # Indexing Methods - def _ixs(self, i: int, axis: Axis = 0): + def _ixs(self, i: int, axis: int = 0): """ Parameters ---------- @@ -3286,17 +3287,20 @@ def _set_item(self, key, value) -> None: self._set_item_mgr(key, value) def _set_value( - self, index: int, col, value: Scalar, takeable: bool = False + self, index: Label, col, value: Scalar, takeable: bool = False ) -> None: """ Put single value at passed column and index. Parameters ---------- - index : row label - col : column label + index : Label + row label + col : Label + column label value : scalar - takeable : interpret the index/col as indexers, default False + takeable : bool, default False + Sets whether or not index/col interpreted as indexers """ try: if takeable is True: @@ -3945,7 +3949,7 @@ def _sanitize_column(self, value): return value @property - def _series(self) -> Dict[int, Series]: + def _series(self) -> Dict[Label, Series]: return { item: Series( self._mgr.iget(idx), index=self.index, name=item, fastpath=True @@ -6097,7 +6101,7 @@ def _arith_op(left, right): new_data = self._dispatch_frame_op(other, _arith_op) return new_data - def _construct_result(self, result): + def _construct_result(self, result) -> DataFrame: """ Wrap the result of an arithmetic, comparison, or logical operation. @@ -8284,7 +8288,7 @@ def merge( ) def round( - self, decimals: Union[int, Dict, Series] = 0, *args, **kwargs + self, decimals: Union[int, Dict[Label, int], Series] = 0, *args, **kwargs ) -> DataFrame: """ Round a DataFrame to a variable number of decimal places. @@ -8400,7 +8404,9 @@ def _series_round(s, decimals): # Statistical methods, etc. def corr( - self, method: Union[str, Callable] = "pearson", min_periods: int = 1 + self, + method: Union[str, Callable[[np.ndarray, np.ndarray], float]] = "pearson", + min_periods: int = 1, ) -> DataFrame: """ Compute pairwise correlation of columns, excluding NA/null values. @@ -9489,7 +9495,12 @@ def to_period( setattr(new_obj, axis_name, new_ax) return new_obj - def isin(self, values: Union[FrameOrSeriesUnion, Dict, Iterable]) -> DataFrame: + def isin( + self, + values: Union[ + FrameOrSeriesUnion, Dict[Label, Iterable[Scalar]], Iterable[Scalar] + ], + ) -> DataFrame: """ Whether each element in the DataFrame is contained in values. From 0e780ce0b8f474e2cae8630567f5f4cac6c730f5 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 4 Jan 2021 20:06:27 -0500 Subject: [PATCH 16/21] review comments --- pandas/_typing.py | 1 + pandas/core/frame.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 0b50dd69f7abb..8f3ef93e27bb0 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -84,6 +84,7 @@ FrameOrSeries = TypeVar("FrameOrSeries", bound="NDFrame") Axis = Union[str, int] +Frequency = Optional[str] Label = Optional[Hashable] IndexLabel = Union[Label, Sequence[Label]] Level = Union[Label, int] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f6636104c9af8..63caf4efce5d8 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -29,7 +29,6 @@ Iterable, Iterator, List, - Mapping, Optional, Sequence, Set, @@ -60,6 +59,7 @@ FloatFormatType, FormattersType, FrameOrSeriesUnion, + Frequency, IndexKeyFunc, IndexLabel, Label, @@ -1435,7 +1435,7 @@ def to_numpy( return result - def to_dict(self, orient: str = "dict", into=dict) -> Union[List, Mapping]: + def to_dict(self, orient: str = "dict", into=dict): """ Convert the DataFrame to a dictionary. @@ -4581,7 +4581,11 @@ def _replace_columnwise( @doc(NDFrame.shift, klass=_shared_doc_kwargs["klass"]) def shift( - self, periods=1, freq=None, axis: Axis = 0, fill_value=lib.no_default + self, + periods=1, + freq: Frequency = None, + axis: Axis = 0, + fill_value=lib.no_default, ) -> DataFrame: axis = self._get_axis_number(axis) @@ -9378,7 +9382,7 @@ def quantile( @doc(NDFrame.asfreq, **_shared_doc_kwargs) def asfreq( self, - freq, + freq: Frequency, method=None, how: Optional[str] = None, normalize: bool = False, @@ -9425,7 +9429,7 @@ def resample( def to_timestamp( self, - freq: Optional[str] = None, + freq: Frequency = None, how: str = "start", axis: Axis = 0, copy: bool = True, @@ -9462,7 +9466,7 @@ def to_timestamp( return new_obj def to_period( - self, freq: Optional[str] = None, axis: Axis = 0, copy: bool = True + self, freq: Frequency = None, axis: Axis = 0, copy: bool = True ) -> DataFrame: """ Convert DataFrame from DatetimeIndex to PeriodIndex. @@ -9497,9 +9501,7 @@ def to_period( def isin( self, - values: Union[ - FrameOrSeriesUnion, Dict[Label, Iterable[Scalar]], Iterable[Scalar] - ], + values, ) -> DataFrame: """ Whether each element in the DataFrame is contained in values. From a93489a4e71c87c5c3679d3da69a3adfe033c6ec Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Wed, 6 Jan 2021 08:35:14 -0500 Subject: [PATCH 17/21] review: remove NpDtype usage --- pandas/core/frame.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 63caf4efce5d8..6efb1a4e3e257 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -64,7 +64,6 @@ IndexLabel, Label, Level, - NpDtype, PythonFuncType, Renamer, Scalar, @@ -1366,7 +1365,7 @@ def from_dict( def to_numpy( self, - dtype: Optional[NpDtype] = None, + dtype=None, copy: bool = False, na_value: Scalar = lib.no_default, ) -> np.ndarray: From 58fcad886ab24e99ce66079a67fbc8e9dc3c73cd Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Sun, 21 Feb 2021 14:29:08 -0500 Subject: [PATCH 18/21] typing --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 35ff01202fdfb..c8e86fc8fc591 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1373,7 +1373,7 @@ def from_dict( data, orient: str = "columns", dtype: Optional[Dtype] = None, - columns: Optional[IndexLabel] = None, + columns=None, ) -> DataFrame: """ Construct DataFrame from dict of array-like or dicts. @@ -4072,7 +4072,7 @@ def _series(self) -> Dict[IndexLabel, Series]: } def lookup( - self, row_labels: Sequence[IndexLabel], col_labels: IndexLabel + self, row_labels: Sequence[IndexLabel], col_labels: Sequence[IndexLabel] ) -> np.ndarray: """ Label-based "fancy indexing" function for DataFrame. From ff317d35ce096f4841afc38a1b62c1b4d44ae45c Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 22 Feb 2021 11:15:36 -0500 Subject: [PATCH 19/21] restore return type for memory_usage --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c8e86fc8fc591..8f0411e6d44d0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2794,7 +2794,7 @@ def info( show_counts=show_counts, ) - def memory_usage(self, index: bool = True, deep: bool = False): + def memory_usage(self, index: bool = True, deep: bool = False) -> Series: """ Return the memory usage of each column in bytes. From 02647b528234963d89412c0fa26944e70144089e Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 22 Feb 2021 11:16:40 -0500 Subject: [PATCH 20/21] remove return type for _series --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8f0411e6d44d0..03e429e4cbe1a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4063,7 +4063,7 @@ def _sanitize_column(self, value): return value @property - def _series(self) -> Dict[IndexLabel, Series]: + def _series(self): return { item: Series( self._mgr.iget(idx), index=self.index, name=item, fastpath=True From cc517a518e2b2e97fc719fe20105663ee222a1ad Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Mon, 22 Feb 2021 11:17:44 -0500 Subject: [PATCH 21/21] rogue comma --- pandas/core/frame.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 03e429e4cbe1a..8934438e3281a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9620,10 +9620,7 @@ def to_period( setattr(new_obj, axis_name, new_ax) return new_obj - def isin( - self, - values, - ) -> DataFrame: + def isin(self, values) -> DataFrame: """ Whether each element in the DataFrame is contained in values.