1
1
""" common type operations """
2
+ import warnings
3
+
2
4
import numpy as np
3
5
4
6
from pandas ._libs import algos , lib
@@ -287,6 +289,8 @@ def is_datetimetz(arr):
287
289
Check whether an array-like is a datetime array-like with a timezone
288
290
component in its dtype.
289
291
292
+ .. deprecated:: 0.24.0
293
+
290
294
Parameters
291
295
----------
292
296
arr : array-like
@@ -320,12 +324,10 @@ def is_datetimetz(arr):
320
324
True
321
325
"""
322
326
323
- # TODO: do we need this function?
324
- # It seems like a repeat of is_datetime64tz_dtype.
325
-
326
- return ((isinstance (arr , ABCDatetimeIndex ) and
327
- getattr (arr , 'tz' , None ) is not None ) or
328
- is_datetime64tz_dtype (arr ))
327
+ warnings .warn ("'is_datetimetz' is deprecated and will be removed in a "
328
+ "future version. Use 'is_datetime64tz_dtype' instead." ,
329
+ FutureWarning , stacklevel = 2 )
330
+ return is_datetime64tz_dtype (arr )
329
331
330
332
331
333
def is_offsetlike (arr_or_obj ):
@@ -363,6 +365,8 @@ def is_period(arr):
363
365
"""
364
366
Check whether an array-like is a periodical index.
365
367
368
+ .. deprecated:: 0.24.0
369
+
366
370
Parameters
367
371
----------
368
372
arr : array-like
@@ -382,8 +386,10 @@ def is_period(arr):
382
386
True
383
387
"""
384
388
385
- # TODO: do we need this function?
386
- # It seems like a repeat of is_period_arraylike.
389
+ warnings .warn ("'is_period' is deprecated and will be removed in a future "
390
+ "version. Use 'is_period_dtype' or is_period_arraylike' "
391
+ "instead." , FutureWarning , stacklevel = 2 )
392
+
387
393
return isinstance (arr , ABCPeriodIndex ) or is_period_arraylike (arr )
388
394
389
395
@@ -743,8 +749,7 @@ def is_datetimelike(arr):
743
749
744
750
return (is_datetime64_dtype (arr ) or is_datetime64tz_dtype (arr ) or
745
751
is_timedelta64_dtype (arr ) or
746
- isinstance (arr , ABCPeriodIndex ) or
747
- is_datetimetz (arr ))
752
+ isinstance (arr , ABCPeriodIndex ))
748
753
749
754
750
755
def is_dtype_equal (source , target ):
@@ -1050,54 +1055,6 @@ def is_int64_dtype(arr_or_dtype):
1050
1055
return issubclass (tipo , np .int64 )
1051
1056
1052
1057
1053
- def is_int_or_datetime_dtype (arr_or_dtype ):
1054
- """
1055
- Check whether the provided array or dtype is of an
1056
- integer, timedelta64, or datetime64 dtype.
1057
-
1058
- Parameters
1059
- ----------
1060
- arr_or_dtype : array-like
1061
- The array or dtype to check.
1062
-
1063
- Returns
1064
- -------
1065
- boolean : Whether or not the array or dtype is of an
1066
- integer, timedelta64, or datetime64 dtype.
1067
-
1068
- Examples
1069
- --------
1070
- >>> is_int_or_datetime_dtype(str)
1071
- False
1072
- >>> is_int_or_datetime_dtype(int)
1073
- True
1074
- >>> is_int_or_datetime_dtype(float)
1075
- False
1076
- >>> is_int_or_datetime_dtype(np.uint64)
1077
- True
1078
- >>> is_int_or_datetime_dtype(np.datetime64)
1079
- True
1080
- >>> is_int_or_datetime_dtype(np.timedelta64)
1081
- True
1082
- >>> is_int_or_datetime_dtype(np.array(['a', 'b']))
1083
- False
1084
- >>> is_int_or_datetime_dtype(pd.Series([1, 2]))
1085
- True
1086
- >>> is_int_or_datetime_dtype(np.array([], dtype=np.timedelta64))
1087
- True
1088
- >>> is_int_or_datetime_dtype(np.array([], dtype=np.datetime64))
1089
- True
1090
- >>> is_int_or_datetime_dtype(pd.Index([1, 2.])) # float
1091
- False
1092
- """
1093
-
1094
- if arr_or_dtype is None :
1095
- return False
1096
- tipo = _get_dtype_type (arr_or_dtype )
1097
- return (issubclass (tipo , np .integer ) or
1098
- issubclass (tipo , (np .datetime64 , np .timedelta64 )))
1099
-
1100
-
1101
1058
def is_datetime64_any_dtype (arr_or_dtype ):
1102
1059
"""
1103
1060
Check whether the provided array or dtype is of the datetime64 dtype.
@@ -1619,22 +1576,6 @@ def is_float_dtype(arr_or_dtype):
1619
1576
return issubclass (tipo , np .floating )
1620
1577
1621
1578
1622
- def is_floating_dtype (arr_or_dtype ):
1623
- """Check whether the provided array or dtype is an instance of
1624
- numpy's float dtype.
1625
-
1626
- .. deprecated:: 0.20.0
1627
-
1628
- Unlike, `is_float_dtype`, this check is a lot stricter, as it requires
1629
- `isinstance` of `np.floating` and not `issubclass`.
1630
- """
1631
-
1632
- if arr_or_dtype is None :
1633
- return False
1634
- tipo = _get_dtype_type (arr_or_dtype )
1635
- return isinstance (tipo , np .floating )
1636
-
1637
-
1638
1579
def is_bool_dtype (arr_or_dtype ):
1639
1580
"""
1640
1581
Check whether the provided array or dtype is of a boolean dtype.
@@ -1758,7 +1699,7 @@ def is_extension_type(arr):
1758
1699
return True
1759
1700
elif is_sparse (arr ):
1760
1701
return True
1761
- elif is_datetimetz (arr ):
1702
+ elif is_datetime64tz_dtype (arr ):
1762
1703
return True
1763
1704
return False
1764
1705
@@ -1991,7 +1932,7 @@ def _get_dtype_from_object(dtype):
1991
1932
return dtype
1992
1933
elif is_categorical (dtype ):
1993
1934
return CategoricalDtype ().type
1994
- elif is_datetimetz (dtype ):
1935
+ elif is_datetime64tz_dtype (dtype ):
1995
1936
return DatetimeTZDtype (dtype ).type
1996
1937
elif isinstance (dtype , np .dtype ): # dtype object
1997
1938
try :
0 commit comments