Skip to content

Commit ccda597

Browse files
committed
Drop the deprecated Pandas "inplace" kwarg as of PDEP-8
1 parent 00d756f commit ccda597

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎khiops/sklearn/dataset.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,18 +1095,17 @@ def create_table_file_for_khiops(
10951095
column_id: get_khiops_variable_name(column_id)
10961096
for column_id in self.column_ids
10971097
}
1098-
output_dataframe.rename(columns=output_names, inplace=True)
1098+
output_dataframe = output_dataframe.rename(columns=output_names)
10991099
if target_column is not None:
11001100
output_dataframe[get_khiops_variable_name(target_column_id)] = (
11011101
target_column.copy()
11021102
)
11031103

11041104
# Sort by key if requested (as string)
11051105
if sort:
1106-
output_dataframe.sort_values(
1106+
output_dataframe = output_dataframe.sort_values(
11071107
by=self.key,
11081108
key=lambda array: array.astype("str"),
1109-
inplace=True,
11101109
kind="mergesort",
11111110
)
11121111

‎khiops/sklearn/estimators.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ def _transform(
523523
raw_output_table_df, on=deployment_ds.main_table.key
524524
)
525525
if drop_key:
526-
output_table_df.drop(deployment_ds.main_table.key, axis=1, inplace=True)
526+
output_table_df = output_table_df.drop(
527+
deployment_ds.main_table.key, axis=1
528+
)
527529
# On mono-table: Return the read dataframe as-is
528530
else:
529531
output_table_df = raw_output_table_df

‎tests/test_dataset_errors.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def test_pandas_table_column_ids_must_all_be_int_or_str(self):
589589
"""Test that in-memory dataset all columns ids must be int or str"""
590590
spec, _ = self.create_fixture_dataset_spec(multitable=False, schema=None)
591591
features_table = spec["main_table"][0]
592-
features_table.rename(columns={"User_ID": 1}, inplace=True)
592+
features_table = features_table.rename(columns={"User_ID": 1})
593593
with self.assertRaises(TypeError) as context:
594594
PandasTable(name="reviews", dataframe=features_table)
595595
output_error_msg = str(context.exception)

‎tests/test_estimator_attributes.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def test_regressor_attributes_multitable(self):
136136
"""
137137
X, _ = self._create_multitable_input(750)
138138
y = X["main_table"][0]["Commune"]
139-
X["main_table"][0].drop("Commune", axis=1, inplace=True)
139+
X["main_table"] = (
140+
X["main_table"][0].drop("Commune", axis=1),
141+
X["main_table"][1],
142+
)
140143
khr_accidents = KhiopsRegressor(n_trees=0, n_text_features=0)
141144
with warnings.catch_warnings():
142145
warnings.filterwarnings(

0 commit comments

Comments
 (0)