|
41 | 41 | IntCastingNaNError,
|
42 | 42 | LossySetitemError,
|
43 | 43 | )
|
44 |
| -from pandas.util._validators import validate_bool_kwarg |
45 | 44 |
|
46 | 45 | from pandas.core.dtypes.common import (
|
47 | 46 | DT64NS_DTYPE,
|
@@ -952,54 +951,6 @@ def coerce_indexer_dtype(indexer, categories) -> np.ndarray:
|
952 | 951 | return ensure_int64(indexer)
|
953 | 952 |
|
954 | 953 |
|
955 |
| -def soft_convert_objects( |
956 |
| - values: np.ndarray, |
957 |
| - *, |
958 |
| - datetime: bool = True, |
959 |
| - timedelta: bool = True, |
960 |
| - period: bool = True, |
961 |
| - copy: bool = True, |
962 |
| -) -> ArrayLike: |
963 |
| - """ |
964 |
| - Try to coerce datetime, timedelta, and numeric object-dtype columns |
965 |
| - to inferred dtype. |
966 |
| -
|
967 |
| - Parameters |
968 |
| - ---------- |
969 |
| - values : np.ndarray[object] |
970 |
| - datetime : bool, default True |
971 |
| - timedelta : bool, default True |
972 |
| - period : bool, default True |
973 |
| - copy : bool, default True |
974 |
| -
|
975 |
| - Returns |
976 |
| - ------- |
977 |
| - np.ndarray or ExtensionArray |
978 |
| - """ |
979 |
| - validate_bool_kwarg(datetime, "datetime") |
980 |
| - validate_bool_kwarg(timedelta, "timedelta") |
981 |
| - validate_bool_kwarg(copy, "copy") |
982 |
| - |
983 |
| - conversion_count = sum((datetime, timedelta)) |
984 |
| - if conversion_count == 0: |
985 |
| - raise ValueError("At least one of datetime or timedelta must be True.") |
986 |
| - |
987 |
| - # Soft conversions |
988 |
| - if datetime or timedelta or period: |
989 |
| - # GH 20380, when datetime is beyond year 2262, hence outside |
990 |
| - # bound of nanosecond-resolution 64-bit integers. |
991 |
| - converted = lib.maybe_convert_objects( |
992 |
| - values, |
993 |
| - convert_datetime=datetime, |
994 |
| - convert_timedelta=timedelta, |
995 |
| - convert_period=period, |
996 |
| - ) |
997 |
| - if converted is not values: |
998 |
| - return converted |
999 |
| - |
1000 |
| - return values |
1001 |
| - |
1002 |
| - |
1003 | 954 | def convert_dtypes(
|
1004 | 955 | input_array: ArrayLike,
|
1005 | 956 | convert_string: bool = True,
|
|
0 commit comments