8000 CI Remove pandas FutureWarning in scipy-dev build (#24206) · rusdes/scikit-learn@5fd66bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fd66bc

Browse files
authored
CI Remove pandas FutureWarning in scipy-dev build (scikit-learn#24206)
1 parent 547a73c commit 5fd66bc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sklearn/datasets/_arff_parser.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,21 @@ def _pandas_arff_parser(
392392
# `"'some string value'"` with pandas.
393393
single_quote_pattern = re.compile(r"^'(?P<contents>.*)'$")
394394

395-
def strip_quotes_regex(s):
396-
return s.group("contents")
395+
def strip_single_quotes(input_string):
396+
match = re.search(single_quote_pattern, input_string)
397+
if match is None:
398+
return input_string
399+
400+
return match.group("contents")
397401

398402
categorical_columns = [
399403
name
400404
for name, dtype in frame.dtypes.items()
401405
if pd.api.types.is_categorical_dtype(dtype)
402406
]
403407
for col in categorical_columns:
404-
frame[col].cat.categories = frame[col].cat.categories.str.replace(
405-
single_quote_pattern, strip_quotes_regex, regex=True
406-
)
408+
frame[col] = frame[col].cat.rename_categories(strip_single_quotes)
409+
407410
X, y = _post_process_frame(frame, feature_names_to_select, target_names_to_select)
408411

409412
if output_arrays_type == "pandas":

0 commit comments

Comments
 (0)
0