2
2
3
3
from csv import QUOTE_NONNUMERIC
4
4
from functools import partial
5
+ import inspect
5
6
import operator
6
7
from shutil import get_terminal_size
7
8
from typing import (
@@ -394,7 +395,7 @@ def __init__(
394
395
"Allowing scalars in the Categorical constructor is deprecated "
395
396
"and will raise in a future version. Use `[value]` instead" ,
396
397
FutureWarning ,
397
- stacklevel = find_stack_level (),
398
+ stacklevel = find_stack_level (inspect . currentframe () ),
398
399
)
399
400
values = [values ]
400
401
@@ -749,7 +750,7 @@ def categories(self, categories) -> None:
749
750
"Setting categories in-place is deprecated and will raise in a "
750
751
"future version. Use rename_categories instead." ,
751
752
FutureWarning ,
752
- stacklevel = find_stack_level (),
753
+ stacklevel = find_stack_level (inspect . currentframe () ),
753
754
)
754
755
755
756
self ._set_categories (categories )
@@ -873,7 +874,7 @@ def set_ordered(
873
874
"a future version. setting ordered-ness on categories will always "
874
875
"return a new Categorical object." ,
875
876
FutureWarning ,
876
- stacklevel = find_stack_level (),
877
+ stacklevel = find_stack_level (inspect . currentframe () ),
877
878
)
878
879
else :
879
880
inplace = False
@@ -1125,7 +1126,7 @@ def rename_categories(
1125
1126
"a future version. Removing unused categories will always "
1126
1127
"return a new Categorical object." ,
1127
1128
FutureWarning ,
1128
- stacklevel = find_stack_level (),
1129
+ stacklevel = find_stack_level (inspect . currentframe () ),
1129
1130
)
1130
1131
else :
1131
1132
inplace = False
@@ -1189,7 +1190,7 @@ def reorder_categories(self, new_categories, ordered=None, inplace=no_default):
1189
1190
"a future version. Reordering categories will always "
1190
1191
"return a new Categorical object." ,
1191
1192
FutureWarning ,
1192
- stacklevel = find_stack_level (),
1193
+ stacklevel = find_stack_level (inspect . currentframe () ),
1193
1194
)
1194
1195
else :
1195
1196
inplace = False
@@ -1273,7 +1274,7 @@ def add_categories(
1273
1274
"a future version. Removing unused categories will always "
1274
1275
"return a new Categorical object." ,
1275
1276
FutureWarning ,
1276
- stacklevel = find_stack_level (),
1277
+ stacklevel = find_stack_level (inspect . currentframe () ),
1277
1278
)
1278
1279
else :
1279
1280
inplace = False
@@ -1349,7 +1350,7 @@ def remove_categories(self, removals, inplace=no_default):
1349
1350
"a future version. Removing unused categories will always "
1350
1351
"return a new Categorical object." ,
1351
1352
FutureWarning ,
1352
- stacklevel = find_stack_level (),
1353
+ stacklevel = find_stack_level (inspect . currentframe () ),
1353
1354
)
1354
1355
else :
1355
1356
inplace = False
@@ -1437,7 +1438,7 @@ def remove_unused_categories(
1437
1438
"remove_unused_categories is deprecated and "
1438
1439
"will be removed in a future version." ,
1439
1440
FutureWarning ,
1440
- stacklevel = find_stack_level (),
1441
+ stacklevel = find_stack_level (inspect . currentframe () ),
1441
1442
)
1442
1443
else :
1443
1444
inplace = False
@@ -2046,7 +2047,7 @@ def to_dense(self) -> np.ndarray:
2046
2047
"Categorical.to_dense is deprecated and will be removed in "
2047
2048
"a future version. Use np.asarray(cat) instead." ,
2048
2049
FutureWarning ,
2049
- stacklevel = find_stack_level (),
2050
+ stacklevel = find_stack_level (inspect . currentframe () ),
2050
2051
)
2051
2052
return np .asarray (self )
2052
2053
@@ -2063,7 +2064,7 @@ def _codes(self, value: np.ndarray):
2063
2064
"Setting the codes on a Categorical is deprecated and will raise in "
2064
2065
"a future version. Create a new Categorical object instead" ,
2065
2066
FutureWarning ,
2066
- stacklevel = find_stack_level (),
2067
+ stacklevel = find_stack_level (inspect . currentframe () ),
2067
2068
) # GH#40606
2068
2069
NDArrayBacked .__init__ (self , value , self .dtype )
2069
2070
@@ -2088,7 +2089,7 @@ def take_nd(
2088
2089
warn (
2089
2090
"Categorical.take_nd is deprecated, use Categorical.take instead" ,
2090
2091
FutureWarning ,
2091
- stacklevel = find_stack_level (),
2092
+ stacklevel = find_stack_level (inspect . currentframe () ),
2092
2093
)
2093
2094
return self .take (indexer , allow_fill = allow_fill , fill_value = fill_value )
2094
2095
@@ -2381,7 +2382,7 @@ def mode(self, dropna: bool = True) -> Categorical:
2381
2382
"Categorical.mode is deprecated and will be removed in a future version. "
2382
2383
"Use Series.mode instead." ,
2383
2384
FutureWarning ,
2384
- stacklevel = find_stack_level (),
2385
+ stacklevel = find_stack_level (inspect . currentframe () ),
2385
2386
)
2386
2387
return self ._mode (dropna = dropna )
2387
2388
@@ -2524,7 +2525,7 @@ def is_dtype_equal(self, other) -> bool:
2524
2525
"Categorical.is_dtype_equal is deprecated and will be removed "
2525
2526
"in a future version" ,
2526
2527
FutureWarning ,
2527
- stacklevel = find_stack_level (),
2528
+ stacklevel = find_stack_level (inspect . currentframe () ),
2528
2529
)
2529
2530
try :
2530
2531
return self ._categories_match_up_to_permutation (other )
@@ -2648,7 +2649,7 @@ def replace(self, to_replace, value, inplace: bool = False) -> Categorical | Non
2648
2649
"Categorical.replace is deprecated and will be removed in a future "
2649
2650
"version. Use Series.replace directly instead." ,
2650
2651
FutureWarning ,
2651
- stacklevel = find_stack_level (),
2652
+ stacklevel = find_stack_level (inspect . currentframe () ),
2652
2653
)
2653
2654
return self ._replace (to_replace = to_replace , value = value , inplace = inplace )
2654
2655
0 commit comments