11""" common type operations """
2+ import warnings
3+
24import numpy as np
35
46from pandas ._libs import algos , lib
@@ -287,6 +289,8 @@ def is_datetimetz(arr):
287289 Check whether an array-like is a datetime array-like with a timezone
288290 component in its dtype.
289291
292+ .. deprecated:: 0.24.0
293+
290294 Parameters
291295 ----------
292296 arr : array-like
@@ -320,12 +324,10 @@ def is_datetimetz(arr):
320324 True
321325 """
322326
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 )
329331
330332
331333def is_offsetlike (arr_or_obj ):
@@ -363,6 +365,8 @@ def is_period(arr):
363365 """
364366 Check whether an array-like is a periodical index.
365367
368+ .. deprecated:: 0.24.0
369+
366370 Parameters
367371 ----------
368372 arr : array-like
@@ -382,8 +386,10 @@ def is_period(arr):
382386 True
383387 """
384388
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+
387393 return isinstance (arr , ABCPeriodIndex ) or is_period_arraylike (arr )
388394
389395
@@ -743,8 +749,7 @@ def is_datetimelike(arr):
743749
744750 return (is_datetime64_dtype (arr ) or is_datetime64tz_dtype (arr ) or
745751 is_timedelta64_dtype (arr ) or
746- isinstance (arr , ABCPeriodIndex ) or
747- is_datetimetz (arr ))
752+ isinstance (arr , ABCPeriodIndex ))
748753
749754
750755def is_dtype_equal (source , target ):
@@ -1050,54 +1055,6 @@ def is_int64_dtype(arr_or_dtype):
10501055 return issubclass (tipo , np .int64 )
10511056
10521057
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-
11011058def is_datetime64_any_dtype (arr_or_dtype ):
11021059 """
11031060 Check whether the provided array or dtype is of the datetime64 dtype.
@@ -1619,22 +1576,6 @@ def is_float_dtype(arr_or_dtype):
16191576 return issubclass (tipo , np .floating )
16201577
16211578
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-
16381579def is_bool_dtype (arr_or_dtype ):
16391580 """
16401581 Check whether the provided array or dtype is of a boolean dtype.
@@ -1758,7 +1699,7 @@ def is_extension_type(arr):
17581699 return True
17591700 elif is_sparse (arr ):
17601701 return True
1761- elif is_datetimetz (arr ):
1702+ elif is_datetime64tz_dtype (arr ):
17621703 return True
17631704 return False
17641705
@@ -1991,7 +1932,7 @@ def _get_dtype_from_object(dtype):
19911932 return dtype
19921933 elif is_categorical (dtype ):
19931934 return CategoricalDtype ().type
1994- elif is_datetimetz (dtype ):
1935+ elif is_datetime64tz_dtype (dtype ):
19951936 return DatetimeTZDtype (dtype ).type
19961937 elif isinstance (dtype , np .dtype ): # dtype object
19971938 try :
0 commit comments