@@ -390,7 +390,7 @@ def __init__(
390
390
"Allowing scalars in the Categorical constructor is deprecated "
391
391
"and will raise in a future version. Use `[value]` instead" ,
392
392
FutureWarning ,
393
- stacklevel = 2 ,
393
+ stacklevel = find_stack_level () ,
394
394
)
395
395
values = [values ]
396
396
@@ -940,7 +940,7 @@ def set_categories(
940
940
"a future version. Removing unused categories will always "
941
941
"return a new Categorical object." ,
942
942
FutureWarning ,
943
- stacklevel = 2 ,
943
+ stacklevel = find_stack_level () ,
944
944
)
945
945
else :
946
946
inplace = False
@@ -1040,7 +1040,7 @@ def rename_categories(self, new_categories, inplace=no_default):
1040
1040
"a future version. Removing unused categories will always "
1041
1041
"return a new Categorical object." ,
1042
1042
FutureWarning ,
1043
- stacklevel = 2 ,
1043
+ stacklevel = find_stack_level () ,
1044
1044
)
1045
1045
else :
1046
1046
inplace = False
@@ -1172,7 +1172,7 @@ def add_categories(self, new_categories, inplace=no_default):
1172
1172
"a future version. Removing unused categories will always "
1173
1173
"return a new Categorical object." ,
1174
1174
FutureWarning ,
1175
- stacklevel = 2 ,
1175
+ stacklevel = find_stack_level () ,
1176
1176
)
1177
1177
else :
1178
1178
inplace = False
@@ -1247,7 +1247,7 @@ def remove_categories(self, removals, inplace=no_default):
1247
1247
"a future version. Removing unused categories will always "
1248
1248
"return a new Categorical object." ,
1249
1249
FutureWarning ,
1250
- stacklevel = 2 ,
1250
+ stacklevel = find_stack_level () ,
1251
1251
)
1252
1252
else :
1253
1253
inplace = False
@@ -1322,7 +1322,7 @@ def remove_unused_categories(self, inplace=no_default):
1322
1322
"remove_unused_categories is deprecated and "
1323
1323
"will be removed in a future version." ,
1324
1324
FutureWarning ,
1325
- stacklevel = 2 ,
1325
+ stacklevel = find_stack_level () ,
1326
1326
)
1327
1327
else :
1328
1328
inplace = False
@@ -1879,7 +1879,7 @@ def to_dense(self) -> np.ndarray:
1879
1879
"Categorical.to_dense is deprecated and will be removed in "
1880
1880
"a future version. Use np.asarray(cat) instead." ,
1881
1881
FutureWarning ,
1882
- stacklevel = 2 ,
1882
+ stacklevel = find_stack_level () ,
1883
1883
)
1884
1884
return np .asarray (self )
1885
1885
@@ -1896,7 +1896,7 @@ def _codes(self, value: np.ndarray):
1896
1896
"Setting the codes on a Categorical is deprecated and will raise in "
1897
1897
"a future version. Create a new Categorical object instead" ,
1898
1898
FutureWarning ,
1899
- stacklevel = 2 ,
1899
+ stacklevel = find_stack_level () ,
1900
1900
) # GH#40606
1901
1901
NDArrayBacked .__init__ (self , value , self .dtype )
1902
1902
@@ -1919,7 +1919,7 @@ def take_nd(self, indexer, allow_fill: bool = False, fill_value=None):
1919
1919
warn (
1920
1920
"Categorical.take_nd is deprecated, use Categorical.take instead" ,
1921
1921
FutureWarning ,
1922
- stacklevel = 2 ,
1922
+ stacklevel = find_stack_level () ,
1923
1923
)
1924
1924
return self .take (indexer , allow_fill = allow_fill , fill_value = fill_value )
1925
1925
@@ -2339,7 +2339,7 @@ def is_dtype_equal(self, other) -> bool:
2339
2339
"Categorical.is_dtype_equal is deprecated and will be removed "
2340
2340
"in a future version" ,
2341
2341
FutureWarning ,
2342
- stacklevel = 2 ,
2342
+ stacklevel = find_stack_level () ,
2343
2343
)
2344
2344
try :
2345
2345
return self ._categories_match_up_to_permutation (other )
0 commit comments