diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 9d53db4613fca..812bec9d883f3 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -248,6 +248,7 @@ Performance improvements - Performance improvement in :meth:`Series.combine_first` (:issue:`51777`) - Performance improvement in :meth:`MultiIndex.set_levels` and :meth:`MultiIndex.set_codes` when ``verify_integrity=True`` (:issue:`51873`) - Performance improvement in :func:`factorize` for object columns not containing strings (:issue:`51921`) +- Performance improvement in :func:`concat` (:issue:`52291`, :issue:`52290`) - Performance improvement in :class:`Series` reductions (:issue:`52341`) - Performance improvement in :meth:`Series.to_numpy` when dtype is a numpy float dtype and ``na_value`` is ``np.nan`` (:issue:`52430`) - Performance improvement in :meth:`Series.corr` and :meth:`Series.cov` for extension dtypes (:issue:`52502`) diff --git a/pandas/_config/__init__.py b/pandas/_config/__init__.py index d12dd3b4cb8aa..73ed99c3a4640 100644 --- a/pandas/_config/__init__.py +++ b/pandas/_config/__init__.py @@ -30,11 +30,11 @@ from pandas._config.display import detect_console_encoding -def using_copy_on_write(): +def using_copy_on_write() -> bool: _mode_options = _global_config["mode"] return _mode_options["copy_on_write"] and _mode_options["data_manager"] == "block" -def using_nullable_dtypes(): +def using_nullable_dtypes() -> bool: _mode_options = _global_config["mode"] return _mode_options["nullable_dtypes"] diff --git a/pandas/_libs/tslibs/timestamps.pyi b/pandas/_libs/tslibs/timestamps.pyi index 2438daf3e1865..547422f5ec55c 100644 --- a/pandas/_libs/tslibs/timestamps.pyi +++ b/pandas/_libs/tslibs/timestamps.pyi @@ -131,12 +131,13 @@ class Timestamp(datetime): def astimezone(self, tz: _tzinfo | None) -> Self: ... # type: ignore[override] def ctime(self) -> str: ... def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... - # Return type "datetime" of "strptime" incompatible with return type "Timestamp" - # in supertype "datetime" @classmethod - def strptime( # type: ignore[override] - cls, date_string: str, format: str - ) -> datetime: ... + def strptime( + # Note: strptime is actually disabled and raises NotImplementedError + cls, + date_string: str, + format: str, + ) -> Self: ... def utcoffset(self) -> timedelta | None: ... def tzname(self) -> str | None: ... def dst(self) -> timedelta | None: ... diff --git a/pandas/_testing/asserters.py b/pandas/_testing/asserters.py index afdc702b5c1ef..c2ea82061dc63 100644 --- a/pandas/_testing/asserters.py +++ b/pandas/_testing/asserters.py @@ -547,7 +547,7 @@ def assert_period_array_equal(left, right, obj: str = "PeriodArray") -> None: _check_isinstance(left, right, PeriodArray) assert_numpy_array_equal(left._ndarray, right._ndarray, obj=f"{obj}._ndarray") - assert_attr_equal("freq", left, right, obj=obj) + assert_attr_equal("dtype", left, right, obj=obj) def assert_datetime_array_equal( diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 08a3a1fb70bac..34ba4077936ad 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -471,7 +471,7 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> npt.NDArray[np.bool_]: if ( len(values) > 0 - and is_numeric_dtype(values) + and is_numeric_dtype(values.dtype) and not is_signed_integer_dtype(comps) ): # GH#46485 Use object to avoid upcast to float64 later diff --git a/pandas/core/apply.py b/pandas/core/apply.py index 53c63132b2602..18a0fed915384 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -236,7 +236,7 @@ def transform(self) -> DataFrame | Series: # DataFrameGroupBy, BaseWindow, Resampler]"; expected "Union[DataFrame, # Series]" if not isinstance(result, (ABCSeries, ABCDataFrame)) or not result.index.equals( - obj.index # type:ignore[arg-type] + obj.index # type: ignore[arg-type] ): raise ValueError("Function did not transform") diff --git a/pandas/core/arrays/arrow/array.py b/pandas/core/arrays/arrow/array.py index d33d25fb08069..82fc826b81a51 100644 --- a/pandas/core/arrays/arrow/array.py +++ b/pandas/core/arrays/arrow/array.py @@ -1150,7 +1150,7 @@ def _concat_same_type(cls, to_concat) -> Self: """ chunks = [array for ea in to_concat for array in ea._pa_array.iterchunks()] if to_concat[0].dtype == "string": - # StringDtype has no attrivute pyarrow_dtype + # StringDtype has no attribute pyarrow_dtype pa_dtype = pa.string() else: pa_dtype = to_concat[0].dtype.pyarrow_dtype diff --git a/pandas/core/arrays/boolean.py b/pandas/core/arrays/boolean.py index f6bc8a87a4c60..0fb3d19c760be 100644 --- a/pandas/core/arrays/boolean.py +++ b/pandas/core/arrays/boolean.py @@ -13,10 +13,7 @@ missing as libmissing, ) -from pandas.core.dtypes.common import ( - is_list_like, - is_numeric_dtype, -) +from pandas.core.dtypes.common import is_list_like from pandas.core.dtypes.dtypes import register_extension_dtype from pandas.core.dtypes.missing import isna @@ -180,7 +177,7 @@ def coerce_to_array( if isinstance(values, np.ndarray) and values.dtype == np.bool_: if copy: values = values.copy() - elif isinstance(values, np.ndarray) and is_numeric_dtype(values.dtype): + elif isinstance(values, np.ndarray) and values.dtype.kind in "iufcb": mask_values = isna(values) values_bool = np.zeros(len(values), dtype=bool) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index d428f003f6a68..aed80ad5600ff 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -113,7 +113,6 @@ from pandas.core import ( algorithms, nanops, - ops, ) from pandas.core.algorithms import ( checked_add_with_arr, @@ -903,13 +902,7 @@ def _cmp_method(self, other, op): dtype = getattr(other, "dtype", None) if is_object_dtype(dtype): - # We have to use comp_method_OBJECT_ARRAY instead of numpy - # comparison otherwise it would fail to raise when - # comparing tz-aware and tz-naive - result = ops.comp_method_OBJECT_ARRAY( - op, np.asarray(self.astype(object)), other - ) - return result + return op(np.asarray(self, dtype=object), other) if other is NaT: if op is operator.ne: diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index e6c89f65fb90c..f78486fa7d84f 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -1805,21 +1805,6 @@ def _formatter(self, boxed: bool = False): # This will infer the correct formatter from the dtype of the values. return None - # ------------------------------------------------------------------------ - # GroupBy Methods - - def _groupby_op( - self, - *, - how: str, - has_dropped_na: bool, - min_count: int, - ngroups: int, - ids: npt.NDArray[np.intp], - **kwargs, - ): - raise NotImplementedError(f"{self.dtype} dtype not supported") - def _make_sparse( arr: np.ndarray, diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index ace668d6ef7ee..ede5fc4809d9c 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -25,10 +25,8 @@ DT64NS_DTYPE, TD64NS_DTYPE, ensure_object, - is_bool_dtype, is_dtype_equal, is_extension_array_dtype, - is_integer_dtype, is_object_dtype, is_scalar, is_string_or_object_np_dtype, @@ -431,23 +429,6 @@ def notna(obj: object) -> bool | npt.NDArray[np.bool_] | NDFrame: notnull = notna -def isna_compat(arr, fill_value=np.nan) -> bool: - """ - Parameters - ---------- - arr: a numpy array - fill_value: fill value, default to np.nan - - Returns - ------- - True if we can fill using this fill_value - """ - if isna(fill_value): - dtype = arr.dtype - return not (is_bool_dtype(dtype) or is_integer_dtype(dtype)) - return True - - def array_equivalent( left, right, diff --git a/pandas/core/frame.py b/pandas/core/frame.py index fa36fef29979c..0ea462878f564 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -278,15 +278,8 @@ axis : int or str, optional Axis to target. Can be either the axis name ('index', 'columns') or number (0, 1).""", - "replace_iloc": """ - This differs from updating with ``.loc`` or ``.iloc``, which require - you to specify a location to update with some value.""", } -_numeric_only_doc = """numeric_only : bool, default False - Include only float, int, boolean data. -""" - _merge_doc = """ Merge DataFrame or named Series objects with a database-style join. @@ -5736,7 +5729,7 @@ def set_index( # error: Argument 1 to "append" of "list" has incompatible type # "Union[Index, Series]"; expected "Index" - arrays.append(col) # type:ignore[arg-type] + arrays.append(col) # type: ignore[arg-type] names.append(col.name) elif isinstance(col, (list, np.ndarray)): # error: Argument 1 to "append" of "list" has incompatible type @@ -7791,10 +7784,7 @@ def _flex_arith_method( # through the DataFrame path raise NotImplementedError(f"fill_value {fill_value} not supported.") - other = ops.maybe_prepare_scalar_for_op( - other, - self.shape, - ) + other = ops.maybe_prepare_scalar_for_op(other, self.shape) self, other = self._align_for_op(other, axis, flex=True, level=level) with np.errstate(all="ignore"): diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 907f7264ad144..e16ef3580d96f 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -212,16 +212,12 @@ "axes": "keywords for axes", "klass": "Series/DataFrame", "axes_single_arg": "{0 or 'index'} for Series, {0 or 'index', 1 or 'columns'} for DataFrame", # noqa:E501 - "args_transpose": "axes to permute (int or label for object)", "inplace": """ inplace : bool, default False If True, performs operation inplace and returns None.""", "optional_by": """ by : str or list of str Name or list of names to sort by""", - "replace_iloc": """ - This differs from updating with ``.loc`` or ``.iloc``, which require - you to specify a location to update with some value.""", } @@ -264,22 +260,11 @@ class NDFrame(PandasObject, indexing.IndexingMixin): # ---------------------------------------------------------------------- # Constructors - def __init__( - self, - data: Manager, - copy: bool_t = False, - attrs: Mapping[Hashable, Any] | None = None, - ) -> None: - # copy kwarg is retained for mypy compat, is not used - + def __init__(self, data: Manager) -> None: object.__setattr__(self, "_is_copy", None) object.__setattr__(self, "_mgr", data) object.__setattr__(self, "_item_cache", {}) - if attrs is None: - attrs = {} - else: - attrs = dict(attrs) - object.__setattr__(self, "_attrs", attrs) + object.__setattr__(self, "_attrs", {}) object.__setattr__(self, "_flags", Flags(self, allows_duplicate_labels=True)) @final @@ -313,6 +298,7 @@ def _init_mgr( mgr = mgr.astype(dtype=dtype) return mgr + @final def _as_manager(self, typ: str, copy: bool_t = True) -> Self: """ Private helper function to create a DataFrame with specific manager. @@ -7314,7 +7300,6 @@ def replace( _shared_docs["replace"], klass=_shared_doc_kwargs["klass"], inplace=_shared_doc_kwargs["inplace"], - replace_iloc=_shared_doc_kwargs["replace_iloc"], ) def replace( self, diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 8b191897e9409..0a56fa4d031d6 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -431,7 +431,7 @@ def _outer_indexer( @cache_readonly def _can_hold_strings(self) -> bool: - return not is_numeric_dtype(self) + return not is_numeric_dtype(self.dtype) _engine_types: dict[np.dtype | ExtensionDtype, type[libindex.IndexEngine]] = { np.dtype(np.int8): libindex.Int8Engine, @@ -3307,6 +3307,8 @@ def _wrap_setop_result(self, other: Index, result) -> Index: @final def intersection(self, other, sort: bool = False): + # default sort keyword is different here from other setops intentionally + # done in GH#25063 """ Form the intersection of two Index objects. diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index fd8d602118f6a..4854a919fb272 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -29,7 +29,6 @@ contains, ) from pandas.core.construction import extract_array -import pandas.core.indexes.base as ibase from pandas.core.indexes.base import ( Index, maybe_extract_name, @@ -47,8 +46,6 @@ DtypeObj, npt, ) -_index_doc_kwargs: dict[str, str] = dict(ibase._index_doc_kwargs) -_index_doc_kwargs.update({"target_klass": "CategoricalIndex"}) @inherit_names( diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index 9e7fc719f24bd..02ec0b1d92406 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -64,7 +64,10 @@ ) from pandas import Index - from pandas.core.internals.blocks import Block + from pandas.core.internals.blocks import ( + Block, + BlockPlacement, + ) def _concatenate_array_managers( @@ -317,7 +320,9 @@ def _maybe_reindex_columns_na_proxy( return new_mgrs_indexers -def _get_mgr_concatenation_plan(mgr: BlockManager): +def _get_mgr_concatenation_plan( + mgr: BlockManager, +) -> list[tuple[BlockPlacement, JoinUnit]]: """ Construct concatenation plan for given block manager. diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 0beb788acd01c..5a150c34da58b 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -44,7 +44,6 @@ needs_i8_conversion, pandas_dtype, ) -from pandas.core.dtypes.dtypes import PeriodDtype from pandas.core.dtypes.missing import ( isna, na_value_for_dtype, @@ -669,7 +668,6 @@ def _mask_datetimelike_result( return result -@disallow(PeriodDtype) @bottleneck_switch() @_datetimelike_compat def nanmean( @@ -808,7 +806,7 @@ def get_median(x, _mask=None): # empty set so return nans of shape "everything but the passed axis" # since "axis" is where the reduction would occur if we had a nonempty # array - res = get_empty_reduction_result(values.shape, axis, np.float_, np.nan) + res = _get_empty_reduction_result(values.shape, axis) else: # otherwise return a scalar value @@ -816,21 +814,17 @@ def get_median(x, _mask=None): return _wrap_results(res, dtype) -def get_empty_reduction_result( - shape: tuple[int, ...], +def _get_empty_reduction_result( + shape: Shape, axis: AxisInt, - dtype: np.dtype | type[np.floating], - fill_value: Any, ) -> np.ndarray: """ The result from a reduction on an empty ndarray. Parameters ---------- - shape : Tuple[int] + shape : Tuple[int, ...] axis : int - dtype : np.dtype - fill_value : Any Returns ------- @@ -838,8 +832,8 @@ def get_empty_reduction_result( """ shp = np.array(shape) dims = np.arange(len(shape)) - ret = np.empty(shp[dims != axis], dtype=dtype) - ret.fill(fill_value) + ret = np.empty(shp[dims != axis], dtype=np.float64) + ret.fill(np.nan) return ret diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index b2ea8102e2747..ae889a7fdbc24 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -62,13 +62,9 @@ } -COMPARISON_BINOPS: set[str] = {"eq", "ne", "lt", "gt", "le", "ge"} - - __all__ = [ "ARITHMETIC_BINOPS", "arithmetic_op", - "COMPARISON_BINOPS", "comparison_op", "comp_method_OBJECT_ARRAY", "invalid_comparison", diff --git a/pandas/core/ops/array_ops.py b/pandas/core/ops/array_ops.py index 5032db0cc2f48..d8960d4faf0cc 100644 --- a/pandas/core/ops/array_ops.py +++ b/pandas/core/ops/array_ops.py @@ -140,7 +140,7 @@ def _masked_arith_op(x: np.ndarray, y, op): # For Series `x` is 1D so ravel() is a no-op; calling it anyway makes # the logic valid for both Series and DataFrame ops. xrav = x.ravel() - assert isinstance(x, np.ndarray), type(x) + if isinstance(y, np.ndarray): dtype = find_common_type([x.dtype, y.dtype]) result = np.empty(x.size, dtype=dtype) @@ -398,7 +398,6 @@ def logical_op(left: ArrayLike, right: Any, op) -> ArrayLike: ------- ndarray or ExtensionArray """ - fill_int = lambda x: x def fill_bool(x, left=None): # if `left` is specifically not-boolean, we do not cast to bool @@ -413,8 +412,6 @@ def fill_bool(x, left=None): x = x.astype(bool) return x - is_self_int_dtype = is_integer_dtype(left.dtype) - right = lib.item_from_zerodim(right) if is_list_like(right) and not hasattr(right, "dtype"): # e.g. list, tuple @@ -439,19 +436,19 @@ def fill_bool(x, left=None): else: if isinstance(rvalues, np.ndarray): is_other_int_dtype = is_integer_dtype(rvalues.dtype) - rvalues = rvalues if is_other_int_dtype else fill_bool(rvalues, lvalues) + if not is_other_int_dtype: + rvalues = fill_bool(rvalues, lvalues) else: # i.e. scalar is_other_int_dtype = lib.is_integer(rvalues) + res_values = na_logical_op(lvalues, rvalues, op) + # For int vs int `^`, `|`, `&` are bitwise operators and return # integer dtypes. Otherwise these are boolean ops - filler = fill_int if is_self_int_dtype and is_other_int_dtype else fill_bool - - res_values = na_logical_op(lvalues, rvalues, op) - # error: Cannot call function of unknown type - res_values = filler(res_values) # type: ignore[operator] + if not (is_integer_dtype(left.dtype) and is_other_int_dtype): + res_values = fill_bool(res_values) return res_values diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index 9e9711707f688..018075c1687fe 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -23,13 +23,15 @@ from pandas.util._decorators import cache_readonly from pandas.util._exceptions import find_stack_level -from pandas.core.dtypes.common import is_iterator +from pandas.core.dtypes.common import ( + is_bool, + is_iterator, +) from pandas.core.dtypes.concat import concat_compat from pandas.core.dtypes.generic import ( ABCDataFrame, ABCSeries, ) -from pandas.core.dtypes.inference import is_bool from pandas.core.dtypes.missing import isna from pandas.core.arrays.categorical import ( diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 9321c6163e99c..ebba3ae14f797 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -245,7 +245,7 @@ def __internal_pivot_table( # discard the top level if values_passed and not values_multi and table.columns.nlevels > 1: - table = table.droplevel(0, axis=1) + table.columns = table.columns.droplevel(0) if len(index) == 0 and len(columns) > 0: table = table.T diff --git a/pandas/core/reshape/tile.py b/pandas/core/reshape/tile.py index 4854a0c853761..ccb53efbdcf6e 100644 --- a/pandas/core/reshape/tile.py +++ b/pandas/core/reshape/tile.py @@ -255,11 +255,7 @@ def cut( if is_scalar(bins) and bins < 1: raise ValueError("`bins` should be a positive integer.") - try: # for array-like - sz = x.size - except AttributeError: - x = np.asarray(x) - sz = x.size + sz = x.size if sz == 0: raise ValueError("Cannot cut empty array") @@ -489,7 +485,7 @@ def _coerce_to_type(x): """ dtype: DtypeObj | None = None - if is_datetime64tz_dtype(x.dtype): + if isinstance(x.dtype, DatetimeTZDtype): dtype = x.dtype elif is_datetime64_dtype(x.dtype): x = to_datetime(x).astype("datetime64[ns]", copy=False) @@ -534,7 +530,7 @@ def _convert_bin_to_numeric_type(bins, dtype: DtypeObj | None): bins = to_timedelta(bins).view(np.int64) else: raise ValueError("bins must be of timedelta64 dtype") - elif is_datetime64_dtype(dtype) or is_datetime64tz_dtype(dtype): + elif is_datetime64_dtype(dtype) or isinstance(dtype, DatetimeTZDtype): if bins_dtype in ["datetime", "datetime64"]: bins = to_datetime(bins) if is_datetime64_dtype(bins): @@ -621,7 +617,7 @@ def _preprocess_for_cut(x): return x -def _postprocess_for_cut(fac, bins, retbins: bool, dtype, original): +def _postprocess_for_cut(fac, bins, retbins: bool, dtype: DtypeObj | None, original): """ handles post processing for the cut method where we combine the index information if the originally passed diff --git a/pandas/core/series.py b/pandas/core/series.py index c60bb93a2320c..e11eda33b2e34 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -195,16 +195,12 @@ "unique": "np.ndarray", "duplicated": "Series", "optional_by": "", - "optional_mapper": "", "optional_reindex": """ index : array-like, optional New labels for the index. Preferably an Index object to avoid duplicating data. axis : int or str, optional Unused.""", - "replace_iloc": """ - This differs from updating with ``.loc`` or ``.iloc``, which require - you to specify a location to update with some value.""", } @@ -2422,9 +2418,8 @@ def idxmin(self, axis: Axis = 0, skipna: bool = True, *args, **kwargs) -> Hashab >>> s.idxmin(skipna=False) nan """ - # error: Argument 1 to "argmin" of "IndexOpsMixin" has incompatible type "Union - # [int, Literal['index', 'columns']]"; expected "Optional[int]" - i = self.argmin(axis, skipna, *args, **kwargs) # type: ignore[arg-type] + axis = self._get_axis_number(axis) + i = self.argmin(axis, skipna, *args, **kwargs) if i == -1: return np.nan return self.index[i] @@ -2493,9 +2488,8 @@ def idxmax(self, axis: Axis = 0, skipna: bool = True, *args, **kwargs) -> Hashab >>> s.idxmax(skipna=False) nan """ - # error: Argument 1 to "argmax" of "IndexOpsMixin" has incompatible type - # "Union[int, Literal['index', 'columns']]"; expected "Optional[int]" - i = self.argmax(axis, skipna, *args, **kwargs) # type: ignore[arg-type] + axis = self._get_axis_number(axis) + i = self.argmax(axis, skipna, *args, **kwargs) if i == -1: return np.nan return self.index[i] diff --git a/pandas/core/shared_docs.py b/pandas/core/shared_docs.py index 30ec5baf227eb..6fbc8748c178d 100644 --- a/pandas/core/shared_docs.py +++ b/pandas/core/shared_docs.py @@ -500,7 +500,8 @@ Replace values given in `to_replace` with `value`. Values of the {klass} are replaced with other values dynamically. - {replace_iloc} + This differs from updating with ``.loc`` or ``.iloc``, which require + you to specify a location to update with some value. Parameters ---------- diff --git a/pandas/core/window/common.py b/pandas/core/window/common.py index b6c7bc5684d20..fc8eddca09c84 100644 --- a/pandas/core/window/common.py +++ b/pandas/core/window/common.py @@ -165,4 +165,5 @@ def prep_binary(arg1, arg2): # mask out values, this also makes a common index... X = arg1 + 0 * arg2 Y = arg2 + 0 * arg1 + return X, Y diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index f7c703949db2d..954ac25883e73 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -46,6 +46,10 @@ # TODO(ArrayManager) fastparquet relies on BlockManager internals +pytestmark = pytest.mark.filterwarnings( + "ignore:DataFrame._data is deprecated:FutureWarning" +) + # setup engines & skips @pytest.fixture( diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 3cf8c648917fe..8c5a55eb29eeb 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -33,7 +33,6 @@ from pandas.core.dtypes.common import ( is_datetime64_dtype, is_datetime64tz_dtype, - is_numeric_dtype, is_timedelta64_dtype, ) from pandas.core.dtypes.dtypes import PeriodDtype @@ -176,7 +175,7 @@ def infer_freq( return inferer.get_freq() if isinstance(index, Index) and not isinstance(index, DatetimeIndex): - if is_numeric_dtype(index): + if index.dtype.kind in "iufcb": raise TypeError( f"cannot infer freq from a non-convertible index of dtype {index.dtype}" ) diff --git a/scripts/validate_unwanted_patterns.py b/scripts/validate_unwanted_patterns.py index 394d1f8d4a99b..168846cd04c59 100755 --- a/scripts/validate_unwanted_patterns.py +++ b/scripts/validate_unwanted_patterns.py @@ -33,15 +33,11 @@ "_apply_docs", "_new_Index", "_new_PeriodIndex", - "_doc_template", "_agg_template_series", "_agg_template_frame", "_pipe_template", "__main__", "_transform_template", - "_flex_comp_doc_FRAME", - "_op_descriptions", - "_IntegerDtype", "_use_inf_as_na", "_get_plot_backend", "_matplotlib",