@@ -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
@@ -945,7 +945,7 @@ def set_categories(
945
945
"a future version. Removing unused categories will always "
946
946
"return a new Categorical object." ,
947
947
FutureWarning ,
948
- stacklevel = 2 ,
948
+ stacklevel = find_stack_level () ,
949
949
)
950
950
else :
951
951
inplace = False
@@ -1045,7 +1045,7 @@ def rename_categories(self, new_categories, inplace=no_default):
1045
1045
"a future version. Removing unused categories will always "
1046
1046
"return a new Categorical object." ,
1047
1047
FutureWarning ,
1048
- stacklevel = 2 ,
1048
+ stacklevel = find_stack_level () ,
1049
1049
)
1050
1050
else :
1051
1051
inplace = False
@@ -1177,7 +1177,7 @@ def add_categories(self, new_categories, inplace=no_default):
1177
1177
"a future version. Removing unused categories will always "
1178
1178
"return a new Categorical object." ,
1179
1179
FutureWarning ,
1180
- stacklevel = 2 ,
1180
+ stacklevel = find_stack_level () ,
1181
1181
)
1182
1182
else :
1183
1183
inplace = False
@@ -1252,7 +1252,7 @@ def remove_categories(self, removals, inplace=no_default):
1252
1252
"a future version. Removing unused categories will always "
1253
1253
"return a new Categorical object." ,
1254
1254
FutureWarning ,
1255
- stacklevel = 2 ,
1255
+ stacklevel = find_stack_level () ,
1256
1256
)
1257
1257
else :
1258
1258
inplace = False
@@ -1327,7 +1327,7 @@ def remove_unused_categories(self, inplace=no_default):
1327
1327
"remove_unused_categories is deprecated and "
1328
1328
"will be removed in a future version." ,
1329
1329
FutureWarning ,
1330
- stacklevel = 2 ,
1330
+ stacklevel = find_stack_level () ,
1331
1331
)
1332
1332
else :
1333
1333
inplace = False
@@ -1884,7 +1884,7 @@ def to_dense(self) -> np.ndarray:
1884
1884
"Categorical.to_dense is deprecated and will be removed in "
1885
1885
"a future version. Use np.asarray(cat) instead." ,
1886
1886
FutureWarning ,
1887
- stacklevel = 2 ,
1887
+ stacklevel = find_stack_level () ,
1888
1888
)
1889
1889
return np .asarray (self )
1890
1890
@@ -1901,7 +1901,7 @@ def _codes(self, value: np.ndarray):
1901
1901
"Setting the codes on a Categorical is deprecated and will raise in "
1902
1902
"a future version. Create a new Categorical object instead" ,
1903
1903
FutureWarning ,
1904
- stacklevel = 2 ,
1904
+ stacklevel = find_stack_level () ,
1905
1905
) # GH#40606
1906
1906
NDArrayBacked .__init__ (self , value , self .dtype )
1907
1907
@@ -1924,7 +1924,7 @@ def take_nd(self, indexer, allow_fill: bool = False, fill_value=None):
1924
1924
warn (
1925
1925
"Categorical.take_nd is deprecated, use Categorical.take instead" ,
1926
1926
FutureWarning ,
1927
- stacklevel = 2 ,
1927
+ stacklevel = find_stack_level () ,
1928
1928
)
1929
1929
return self .take (indexer , allow_fill = allow_fill , fill_value = fill_value )
1930
1930
@@ -2344,7 +2344,7 @@ def is_dtype_equal(self, other) -> bool:
2344
2344
"Categorical.is_dtype_equal is deprecated and will be removed "
2345
2345
"in a future version" ,
2346
2346
FutureWarning ,
2347
- stacklevel = 2 ,
2347
+ stacklevel = find_stack_level () ,
2348
2348
)
2349
2349
try :
2350
2350
return self ._categories_match_up_to_permutation (other )
0 commit comments