Skip to content

Commit 4726b84

Browse files
jrebackharisbal
authored and
harisbal
committed
DEPR: remove pandas.core.common is_* (pandas-dev#19769)
1 parent 0bfda02 commit 4726b84

File tree

5 files changed

+30
-110
lines changed

5 files changed

+30
-110
lines changed

doc/source/whatsnew/v0.23.0.txt

+18
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ Convert to an xarray DataArray
345345

346346
p.to_xarray()
347347

348+
349+
350+
.. _whatsnew_0230.api_breaking.core_common:
351+
352+
pandas.core.common removals
353+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
354+
355+
The following error & warning messages are removed from ``pandas.core.common`` (:issue:`13634`, :issue:`19769`):
356+
357+
- ``PerformanceWarning``
358+
- ``UnsupportedFunctionCall``
359+
- ``UnsortedIndexError``
360+
- ``AbstractMethodError``
361+
362+
These are available from import from ``pandas.errors`` (since 0.19.0).
363+
364+
348365
.. _whatsnew_0230.api_breaking.apply:
349366

350367
Changes to make output of ``DataFrame.apply`` consistent
@@ -644,6 +661,7 @@ Removal of prior version deprecations/changes
644661
- The modules ``pandas.tools.hashing`` and ``pandas.util.hashing`` have been removed (:issue:`16223`)
645662
- The top-level functions ``pd.rolling_*``, ``pd.expanding_*`` and ``pd.ewm*`` have been removed (Deprecated since v0.18).
646663
Instead, use the DataFrame/Series methods :attr:`~DataFrame.rolling`, :attr:`~DataFrame.expanding` and :attr:`~DataFrame.ewm` (:issue:`18723`)
664+
- Imports from ``pandas.core.common`` for functions such as ``is_datetime64_dtype`` are now removed. These are located in ``pandas.api.types``. (:issue:`13634`, :issue:`19769`)
647665

648666
.. _whatsnew_0230.performance:
649667

pandas/core/base.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
is_extension_array_dtype)
1818

1919
from pandas.util._validators import validate_bool_kwarg
20-
20+
from pandas.errors import AbstractMethodError
2121
from pandas.core import common as com, algorithms
2222
import pandas.core.nanops as nanops
2323
import pandas._libs.lib as lib
@@ -46,7 +46,7 @@ class StringMixin(object):
4646
# Formatting
4747

4848
def __unicode__(self):
49-
raise com.AbstractMethodError(self)
49+
raise AbstractMethodError(self)
5050

5151
def __str__(self):
5252
"""
@@ -278,10 +278,10 @@ def _gotitem(self, key, ndim, subset=None):
278278
subset to act on
279279
280280
"""
281-
raise com.AbstractMethodError(self)
281+
raise AbstractMethodError(self)
282282

283283
def aggregate(self, func, *args, **kwargs):
284-
raise com.AbstractMethodError(self)
284+
raise AbstractMethodError(self)
285285

286286
agg = aggregate
287287

@@ -1247,4 +1247,4 @@ def duplicated(self, keep='first'):
12471247
# abstracts
12481248

12491249
def _update_inplace(self, result, **kwargs):
1250-
raise com.AbstractMethodError(self)
1250+
raise AbstractMethodError(self)

pandas/core/common.py

-60
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Misc tools for implementing data structures
33
"""
44

5-
import sys
6-
import warnings
75
from datetime import datetime, timedelta
86
from functools import partial
97
import inspect
@@ -20,66 +18,8 @@
2018
from pandas.core.dtypes.inference import _iterable_not_string
2119
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
2220
from pandas.api import types
23-
from pandas.core.dtypes import common
2421
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
2522

26-
# compat
27-
from pandas.errors import ( # noqa
28-
PerformanceWarning, UnsupportedFunctionCall, UnsortedIndexError,
29-
AbstractMethodError)
30-
31-
# back-compat of public API
32-
# deprecate these functions
33-
m = sys.modules['pandas.core.common']
34-
for t in [t for t in dir(types) if not t.startswith('_')]:
35-
36-
def outer(t=t):
37-
38-
def wrapper(*args, **kwargs):
39-
warnings.warn("pandas.core.common.{t} is deprecated. "
40-
"import from the public API: "
41-
"pandas.api.types.{t} instead".format(t=t),
42-
DeprecationWarning, stacklevel=3)
43-
return getattr(types, t)(*args, **kwargs)
44-
return wrapper
45-
46-
setattr(m, t, outer(t))
47-
48-
# back-compat for non-public functions
49-
# deprecate these functions
50-
for t in ['is_datetime_arraylike',
51-
'is_datetime_or_timedelta_dtype',
52-
'is_datetimelike',
53-
'is_datetimelike_v_numeric',
54-
'is_datetimelike_v_object',
55-
'is_datetimetz',
56-
'is_int_or_datetime_dtype',
57-
'is_period_arraylike',
58-
'is_string_like',
59-
'is_string_like_dtype']:
60-
61-
def outer(t=t):
62-
63-
def wrapper(*args, **kwargs):
64-
warnings.warn("pandas.core.common.{t} is deprecated. "
65-
"These are not longer public API functions, "
66-
"but can be imported from "
67-
"pandas.api.types.{t} instead".format(t=t),
68-
DeprecationWarning, stacklevel=3)
69-
return getattr(common, t)(*args, **kwargs)
70-
return wrapper
71-
72-
setattr(m, t, outer(t))
73-
74-
75-
# deprecate array_equivalent
76-
77-
def array_equivalent(*args, **kwargs):
78-
warnings.warn("'pandas.core.common.array_equivalent' is deprecated and "
79-
"is no longer public API", DeprecationWarning, stacklevel=2)
80-
from pandas.core.dtypes import missing
81-
return missing.array_equivalent(*args, **kwargs)
82-
8323

8424
class SettingWithCopyError(ValueError):
8525
pass

pandas/core/resample.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pandas.core.indexes.timedeltas import TimedeltaIndex
1717
from pandas.tseries.offsets import DateOffset, Tick, Day, delta_to_nanoseconds
1818
from pandas.core.indexes.period import PeriodIndex
19-
import pandas.core.common as com
19+
from pandas.errors import AbstractMethodError
2020
import pandas.core.algorithms as algos
2121
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
2222

@@ -205,10 +205,10 @@ def __setattr__(self, attr, value):
205205
def __getitem__(self, key):
206206
try:
207207
return super(Resampler, self).__getitem__(key)
208-
except (KeyError, com.AbstractMethodError):
208+
except (KeyError, AbstractMethodError):
209209

210210
# compat for deprecated
211-
if isinstance(self.obj, com.ABCSeries):
211+
if isinstance(self.obj, ABCSeries):
212212
return self._deprecated('__getitem__')[key]
213213

214214
raise
@@ -233,7 +233,7 @@ def _convert_obj(self, obj):
233233
return obj
234234

235235
def _get_binner_for_time(self):
236-
raise com.AbstractMethodError(self)
236+
raise AbstractMethodError(self)
237237

238238
def _set_binner(self):
239239
"""
@@ -372,10 +372,10 @@ def transform(self, arg, *args, **kwargs):
372372
arg, *args, **kwargs)
373373

374374
def _downsample(self, f):
375-
raise com.AbstractMethodError(self)
375+
raise AbstractMethodError(self)
376376

377377
def _upsample(self, f, limit=None, fill_value=None):
378-
raise com.AbstractMethodError(self)
378+
raise AbstractMethodError(self)
379379

380380
def _gotitem(self, key, ndim, subset=None):
381381
"""
@@ -464,7 +464,7 @@ def _get_resampler_for_grouping(self, groupby, **kwargs):
464464

465465
def _wrap_result(self, result):
466466
""" potentially wrap any results """
467-
if isinstance(result, com.ABCSeries) and self._selection is not None:
467+
if isinstance(result, ABCSeries) and self._selection is not None:
468468
result.name = self._selection
469469

470470
if isinstance(result, ABCSeries) and result.empty:

pandas/tests/api/test_types.py

-38
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import pytest
44

55
from warnings import catch_warnings
6-
import numpy as np
76

87
import pandas
9-
from pandas.core import common as com
108
from pandas.api import types
119
from pandas.util import testing as tm
1210

@@ -52,42 +50,6 @@ def check_deprecation(self, fold, fnew):
5250
except AttributeError:
5351
pytest.raises(AttributeError, lambda: fnew('foo'))
5452

55-
def test_deprecation_core_common(self):
56-
57-
# test that we are in fact deprecating
58-
# the pandas.core.common introspectors
59-
for t in self.allowed:
60-
self.check_deprecation(getattr(com, t), getattr(types, t))
61-
62-
def test_deprecation_core_common_array_equivalent(self):
63-
64-
with tm.assert_produces_warning(DeprecationWarning):
65-
com.array_equivalent(np.array([1, 2]), np.array([1, 2]))
66-
67-
def test_deprecation_core_common_moved(self):
68-
69-
# these are in pandas.core.dtypes.common
70-
l = ['is_datetime_arraylike',
71-
'is_datetime_or_timedelta_dtype',
72-
'is_datetimelike',
73-
'is_datetimelike_v_numeric',
74-
'is_datetimelike_v_object',
75-
'is_datetimetz',
76-
'is_int_or_datetime_dtype',
77-
'is_period_arraylike',
78-
'is_string_like',
79-
'is_string_like_dtype']
80-
81-
from pandas.core.dtypes import common as c
82-
for t in l:
83-
self.check_deprecation(getattr(com, t), getattr(c, t))
84-
85-
def test_removed_from_core_common(self):
86-
87-
for t in ['is_null_datelike_scalar',
88-
'ensure_float']:
89-
pytest.raises(AttributeError, lambda: getattr(com, t))
90-
9153
def test_deprecated_from_api_types(self):
9254

9355
for t in self.deprecated:

0 commit comments

Comments
 (0)