Skip to content

Commit 2253bdf

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into singletons
2 parents d013103 + 6d3565a commit 2253bdf

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

doc/source/api/general_utility_functions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Dtype introspection
6363
api.types.is_datetime64_ns_dtype
6464
api.types.is_datetime64tz_dtype
6565
api.types.is_extension_type
66+
api.types.is_extension_array_dtype
6667
api.types.is_float_dtype
6768
api.types.is_int64_dtype
6869
api.types.is_integer_dtype

pandas/_libs/tslibs/offsets.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ class _BaseOffset(object):
412412
**self.kwds)
413413

414414
def __neg__(self):
415-
# Note: we are defering directly to __mul__ instead of __rmul__, as
415+
# Note: we are deferring directly to __mul__ instead of __rmul__, as
416416
# that allows us to use methods that can go in a `cdef class`
417417
return self * -1
418418

419419
def copy(self):
420-
# Note: we are defering directly to __mul__ instead of __rmul__, as
420+
# Note: we are deferring directly to __mul__ instead of __rmul__, as
421421
# that allows us to use methods that can go in a `cdef class`
422422
return self * 1
423423

pandas/core/dtypes/api.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
is_categorical_dtype, is_complex, is_complex_dtype,
66
is_datetime64_any_dtype, is_datetime64_dtype, is_datetime64_ns_dtype,
77
is_datetime64tz_dtype, is_datetimetz, is_dict_like, is_dtype_equal,
8-
is_extension_type, is_file_like, is_float, is_float_dtype, is_hashable,
9-
is_int64_dtype, is_integer, is_integer_dtype, is_interval,
10-
is_interval_dtype, is_iterator, is_list_like, is_named_tuple, is_number,
11-
is_numeric_dtype, is_object_dtype, is_period, is_period_dtype, is_re,
12-
is_re_compilable, is_scalar, is_signed_integer_dtype, is_sparse,
8+
is_extension_array_dtype, is_extension_type, is_file_like, is_float,
9+
is_float_dtype, is_hashable, is_int64_dtype, is_integer, is_integer_dtype,
10+
is_interval, is_interval_dtype, is_iterator, is_list_like, is_named_tuple,
11+
is_number, is_numeric_dtype, is_object_dtype, is_period, is_period_dtype,
12+
is_re, is_re_compilable, is_scalar, is_signed_integer_dtype, is_sparse,
1313
is_string_dtype, is_timedelta64_dtype, is_timedelta64_ns_dtype,
1414
is_unsigned_integer_dtype, pandas_dtype)

pandas/core/dtypes/common.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -1700,15 +1700,21 @@ def is_extension_type(arr):
17001700

17011701

17021702
def is_extension_array_dtype(arr_or_dtype):
1703-
"""Check if an object is a pandas extension array type.
1703+
"""
1704+
Check if an object is a pandas extension array type.
1705+
1706+
See the :ref:`Use Guide <extending.extension-types>` for more.
17041707
17051708
Parameters
17061709
----------
17071710
arr_or_dtype : object
1711+
For array-like input, the ``.dtype`` attribute will
1712+
be extracted.
17081713
17091714
Returns
17101715
-------
17111716
bool
1717+
Whether the `arr_or_dtype` is an extension array type.
17121718
17131719
Notes
17141720
-----
@@ -1718,9 +1724,25 @@ def is_extension_array_dtype(arr_or_dtype):
17181724
* Categorical
17191725
* Sparse
17201726
* Interval
1727+
* Period
1728+
* DatetimeArray
1729+
* TimedeltaArray
17211730
17221731
Third-party libraries may implement arrays or types satisfying
17231732
this interface as well.
1733+
1734+
Examples
1735+
--------
1736+
>>> from pandas.api.types import is_extension_array_dtype
1737+
>>> arr = pd.Categorical(['a', 'b'])
1738+
>>> is_extension_array_dtype(arr)
1739+
True
1740+
>>> is_extension_array_dtype(arr.dtype)
1741+
True
1742+
1743+
>>> arr = np.array(['a', 'b'])
1744+
>>> is_extension_array_dtype(arr.dtype)
1745+
False
17241746
"""
17251747
dtype = getattr(arr_or_dtype, 'dtype', arr_or_dtype)
17261748
return (isinstance(dtype, ExtensionDtype) or

pandas/tests/api/test_types.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class TestTypes(Base):
2424
'is_dict_like', 'is_iterator', 'is_file_like',
2525
'is_list_like', 'is_hashable', 'is_array_like',
2626
'is_named_tuple',
27-
'pandas_dtype', 'union_categoricals', 'infer_dtype']
27+
'pandas_dtype', 'union_categoricals', 'infer_dtype',
28+
'is_extension_array_dtype']
2829
deprecated = ['is_period', 'is_datetimetz']
2930
dtypes = ['CategoricalDtype', 'DatetimeTZDtype',
3031
'PeriodDtype', 'IntervalDtype']

0 commit comments

Comments
 (0)