Skip to content

Commit d4ac558

Browse files
committed
DEPR: remove pandas.core.common is_*
xref pandas-dev#13990
1 parent 718d067 commit d4ac558

File tree

5 files changed

+13
-106
lines changed

5 files changed

+13
-106
lines changed

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ Removal of prior version deprecations/changes
624624
- The modules `pandas.tools.hashing` and `pandas.util.hashing` have been removed (:issue:`16223`)
625625
- The top-level functions ``pd.rolling_*``, ``pd.expanding_*`` and ``pd.ewm*`` have been removed (Deprecated since v0.18).
626626
Instead, use the DataFrame/Series methods :attr:`~DataFrame.rolling`, :attr:`~DataFrame.expanding` and :attr:`~DataFrame.ewm` (:issue:`18723`)
627+
- Imports from ``pandas.core.common`` for api like functions such as ``is_datetime64_dtype`` are now removed. These are located in ``pandas.api.types``. Furthermore, errors are removed as well from ``pandas.core.common`` and are available in ``pandas.errors`` (:issue:`13990`)
627628

628629
.. _whatsnew_0230.performance:
629630

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

@@ -1252,4 +1252,4 @@ def duplicated(self, keep='first'):
12521252
# abstracts
12531253

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

pandas/core/common.py

-57
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,6 @@
2323
from pandas.core.dtypes import common
2424
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
2525

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-
8326

8427
class SettingWithCopyError(ValueError):
8528
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

-37
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77

88
import pandas
9-
from pandas.core import common as com
109
from pandas.api import types
1110
from pandas.util import testing as tm
1211

@@ -52,42 +51,6 @@ def check_deprecation(self, fold, fnew):
5251
except AttributeError:
5352
pytest.raises(AttributeError, lambda: fnew('foo'))
5453

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-
9154
def test_deprecated_from_api_types(self):
9255

9356
for t in self.deprecated:

0 commit comments

Comments
 (0)