|
22 | 22 | ) |
23 | 23 | from pandas._libs.tslibs import conversion |
24 | 24 | from pandas.errors import Pandas4Warning |
| 25 | +from pandas.util._decorators import set_module |
25 | 26 | from pandas.util._exceptions import find_stack_level |
26 | 27 |
|
27 | 28 | from pandas.core.dtypes.base import _registry as registry |
@@ -138,6 +139,7 @@ def _classes_and_not_datetimelike(*klasses) -> Callable: |
138 | 139 | ) |
139 | 140 |
|
140 | 141 |
|
| 142 | +@set_module("pandas.api.types") |
141 | 143 | def is_object_dtype(arr_or_dtype) -> bool: |
142 | 144 | """ |
143 | 145 | Check whether an array-like or dtype is of the object dtype. |
@@ -183,6 +185,7 @@ def is_object_dtype(arr_or_dtype) -> bool: |
183 | 185 | return _is_dtype_type(arr_or_dtype, classes(np.object_)) |
184 | 186 |
|
185 | 187 |
|
| 188 | +@set_module("pandas.api.types") |
186 | 189 | def is_sparse(arr) -> bool: |
187 | 190 | """ |
188 | 191 | Check whether an array-like is a 1-D pandas sparse array. |
@@ -282,6 +285,7 @@ def is_scipy_sparse(arr) -> bool: |
282 | 285 | return _is_scipy_sparse(arr) |
283 | 286 |
|
284 | 287 |
|
| 288 | +@set_module("pandas.api.types") |
285 | 289 | def is_datetime64_dtype(arr_or_dtype) -> bool: |
286 | 290 | """ |
287 | 291 | Check whether an array-like or dtype is of the datetime64 dtype. |
@@ -323,6 +327,7 @@ def is_datetime64_dtype(arr_or_dtype) -> bool: |
323 | 327 | return _is_dtype_type(arr_or_dtype, classes(np.datetime64)) |
324 | 328 |
|
325 | 329 |
|
| 330 | +@set_module("pandas.api.types") |
326 | 331 | def is_datetime64tz_dtype(arr_or_dtype) -> bool: |
327 | 332 | """ |
328 | 333 | Check whether an array-like or dtype is of a DatetimeTZDtype dtype. |
@@ -384,6 +389,7 @@ def is_datetime64tz_dtype(arr_or_dtype) -> bool: |
384 | 389 | return DatetimeTZDtype.is_dtype(arr_or_dtype) |
385 | 390 |
|
386 | 391 |
|
| 392 | +@set_module("pandas.api.types") |
387 | 393 | def is_timedelta64_dtype(arr_or_dtype) -> bool: |
388 | 394 | """ |
389 | 395 | Check whether an array-like or dtype is of the timedelta64 dtype. |
@@ -426,6 +432,7 @@ def is_timedelta64_dtype(arr_or_dtype) -> bool: |
426 | 432 | return _is_dtype_type(arr_or_dtype, classes(np.timedelta64)) |
427 | 433 |
|
428 | 434 |
|
| 435 | +@set_module("pandas.api.types") |
429 | 436 | def is_period_dtype(arr_or_dtype) -> bool: |
430 | 437 | """ |
431 | 438 | Check whether an array-like or dtype is of the Period dtype. |
@@ -479,6 +486,7 @@ def is_period_dtype(arr_or_dtype) -> bool: |
479 | 486 | return PeriodDtype.is_dtype(arr_or_dtype) |
480 | 487 |
|
481 | 488 |
|
| 489 | +@set_module("pandas.api.types") |
482 | 490 | def is_interval_dtype(arr_or_dtype) -> bool: |
483 | 491 | """ |
484 | 492 | Check whether an array-like or dtype is of the Interval dtype. |
@@ -537,6 +545,7 @@ def is_interval_dtype(arr_or_dtype) -> bool: |
537 | 545 | return IntervalDtype.is_dtype(arr_or_dtype) |
538 | 546 |
|
539 | 547 |
|
| 548 | +@set_module("pandas.api.types") |
540 | 549 | def is_categorical_dtype(arr_or_dtype) -> bool: |
541 | 550 | """ |
542 | 551 | Check whether an array-like or dtype is of the Categorical dtype. |
@@ -598,6 +607,7 @@ def is_string_or_object_np_dtype(dtype: np.dtype) -> bool: |
598 | 607 | return dtype == object or dtype.kind in "SU" |
599 | 608 |
|
600 | 609 |
|
| 610 | +@set_module("pandas.api.types") |
601 | 611 | def is_string_dtype(arr_or_dtype) -> bool: |
602 | 612 | """ |
603 | 613 | Check whether the provided array or dtype is of the string dtype. |
@@ -650,6 +660,7 @@ def condition(dtype) -> bool: |
650 | 660 | return _is_dtype(arr_or_dtype, condition) |
651 | 661 |
|
652 | 662 |
|
| 663 | +@set_module("pandas.api.types") |
653 | 664 | def is_dtype_equal(source, target) -> bool: |
654 | 665 | """ |
655 | 666 | Check if two dtypes are equal. |
@@ -714,6 +725,7 @@ def is_dtype_equal(source, target) -> bool: |
714 | 725 | return False |
715 | 726 |
|
716 | 727 |
|
| 728 | +@set_module("pandas.api.types") |
717 | 729 | def is_integer_dtype(arr_or_dtype) -> bool: |
718 | 730 | """ |
719 | 731 | Check whether the provided array or dtype is of an integer dtype. |
@@ -780,6 +792,7 @@ def is_integer_dtype(arr_or_dtype) -> bool: |
780 | 792 | ) |
781 | 793 |
|
782 | 794 |
|
| 795 | +@set_module("pandas.api.types") |
783 | 796 | def is_signed_integer_dtype(arr_or_dtype) -> bool: |
784 | 797 | """ |
785 | 798 | Check whether the provided array or dtype is of a signed integer dtype. |
@@ -848,6 +861,7 @@ def is_signed_integer_dtype(arr_or_dtype) -> bool: |
848 | 861 | ) |
849 | 862 |
|
850 | 863 |
|
| 864 | +@set_module("pandas.api.types") |
851 | 865 | def is_unsigned_integer_dtype(arr_or_dtype) -> bool: |
852 | 866 | """ |
853 | 867 | Check whether the provided array or dtype is of an unsigned integer dtype. |
@@ -907,6 +921,7 @@ def is_unsigned_integer_dtype(arr_or_dtype) -> bool: |
907 | 921 | ) |
908 | 922 |
|
909 | 923 |
|
| 924 | +@set_module("pandas.api.types") |
910 | 925 | def is_int64_dtype(arr_or_dtype) -> bool: |
911 | 926 | """ |
912 | 927 | Check whether the provided array or dtype is of the int64 dtype. |
@@ -980,6 +995,7 @@ def is_int64_dtype(arr_or_dtype) -> bool: |
980 | 995 | return _is_dtype_type(arr_or_dtype, classes(np.int64)) |
981 | 996 |
|
982 | 997 |
|
| 998 | +@set_module("pandas.api.types") |
983 | 999 | def is_datetime64_any_dtype(arr_or_dtype) -> bool: |
984 | 1000 | """ |
985 | 1001 | Check whether the provided array or dtype is of the datetime64 dtype. |
@@ -1042,6 +1058,7 @@ def is_datetime64_any_dtype(arr_or_dtype) -> bool: |
1042 | 1058 | ) |
1043 | 1059 |
|
1044 | 1060 |
|
| 1061 | +@set_module("pandas.api.types") |
1045 | 1062 | def is_datetime64_ns_dtype(arr_or_dtype) -> bool: |
1046 | 1063 | """ |
1047 | 1064 | Check whether the provided array or dtype is of the datetime64[ns] dtype. |
@@ -1097,6 +1114,7 @@ def is_datetime64_ns_dtype(arr_or_dtype) -> bool: |
1097 | 1114 | ) |
1098 | 1115 |
|
1099 | 1116 |
|
| 1117 | +@set_module("pandas.api.types") |
1100 | 1118 | def is_timedelta64_ns_dtype(arr_or_dtype) -> bool: |
1101 | 1119 | """ |
1102 | 1120 | Check whether the provided array or dtype is of the timedelta64[ns] dtype. |
@@ -1224,6 +1242,7 @@ def needs_i8_conversion(dtype: DtypeObj | None) -> bool: |
1224 | 1242 | return isinstance(dtype, (PeriodDtype, DatetimeTZDtype)) |
1225 | 1243 |
|
1226 | 1244 |
|
| 1245 | +@set_module("pandas.api.types") |
1227 | 1246 | def is_numeric_dtype(arr_or_dtype) -> bool: |
1228 | 1247 | """ |
1229 | 1248 | Check whether the provided array or dtype is of a numeric dtype. |
@@ -1278,6 +1297,7 @@ def is_numeric_dtype(arr_or_dtype) -> bool: |
1278 | 1297 | ) |
1279 | 1298 |
|
1280 | 1299 |
|
| 1300 | +@set_module("pandas.api.types") |
1281 | 1301 | def is_any_real_numeric_dtype(arr_or_dtype) -> bool: |
1282 | 1302 | """ |
1283 | 1303 | Check whether the provided array or dtype is of a real number dtype. |
@@ -1321,6 +1341,7 @@ def is_any_real_numeric_dtype(arr_or_dtype) -> bool: |
1321 | 1341 | ) |
1322 | 1342 |
|
1323 | 1343 |
|
| 1344 | +@set_module("pandas.api.types") |
1324 | 1345 | def is_float_dtype(arr_or_dtype) -> bool: |
1325 | 1346 | """ |
1326 | 1347 | Check whether the provided array or dtype is of a float dtype. |
@@ -1368,6 +1389,7 @@ def is_float_dtype(arr_or_dtype) -> bool: |
1368 | 1389 | ) |
1369 | 1390 |
|
1370 | 1391 |
|
| 1392 | +@set_module("pandas.api.types") |
1371 | 1393 | def is_bool_dtype(arr_or_dtype) -> bool: |
1372 | 1394 | """ |
1373 | 1395 | Check whether the provided array or dtype is of a boolean dtype. |
@@ -1455,6 +1477,7 @@ def is_1d_only_ea_dtype(dtype: DtypeObj | None) -> bool: |
1455 | 1477 | return isinstance(dtype, ExtensionDtype) and not dtype._supports_2d |
1456 | 1478 |
|
1457 | 1479 |
|
| 1480 | +@set_module("pandas.api.types") |
1458 | 1481 | def is_extension_array_dtype(arr_or_dtype) -> bool: |
1459 | 1482 | """ |
1460 | 1483 | Check if an object is a pandas extension array type. |
@@ -1532,6 +1555,7 @@ def is_ea_or_datetimelike_dtype(dtype: DtypeObj | None) -> bool: |
1532 | 1555 | return isinstance(dtype, ExtensionDtype) or (lib.is_np_dtype(dtype, "mM")) |
1533 | 1556 |
|
1534 | 1557 |
|
| 1558 | +@set_module("pandas.api.types") |
1535 | 1559 | def is_complex_dtype(arr_or_dtype) -> bool: |
1536 | 1560 | """ |
1537 | 1561 | Check whether the provided array or dtype is of a complex dtype. |
@@ -1794,6 +1818,7 @@ def validate_all_hashable(*args, error_name: str | None = None) -> None: |
1794 | 1818 | raise TypeError("All elements must be hashable") |
1795 | 1819 |
|
1796 | 1820 |
|
| 1821 | +@set_module("pandas.api.types") |
1797 | 1822 | def pandas_dtype(dtype) -> DtypeObj: |
1798 | 1823 | """ |
1799 | 1824 | Convert input into a pandas only dtype object or a numpy dtype object. |
|
0 commit comments