Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions khiops/sklearn/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,18 +1095,17 @@ def create_table_file_for_khiops(
column_id: get_khiops_variable_name(column_id)
for column_id in self.column_ids
}
output_dataframe.rename(columns=output_names, inplace=True)
output_dataframe = output_dataframe.rename(columns=output_names)
if target_column is not None:
output_dataframe[get_khiops_variable_name(target_column_id)] = (
target_column.copy()
)

# Sort by key if requested (as string)
if sort:
output_dataframe.sort_values(
output_dataframe = output_dataframe.sort_values(
by=self.key,
key=lambda array: array.astype("str"),
inplace=True,
kind="mergesort",
)

Expand Down
4 changes: 3 additions & 1 deletion khiops/sklearn/estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ def _transform(
raw_output_table_df, on=deployment_ds.main_table.key
)
if drop_key:
output_table_df.drop(deployment_ds.main_table.key, axis=1, inplace=True)
output_table_df = output_table_df.drop(
deployment_ds.main_table.key, axis=1
)
# On mono-table: Return the read dataframe as-is
else:
output_table_df = raw_output_table_df
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dataset_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def test_pandas_table_column_ids_must_all_be_int_or_str(self):
"""Test that in-memory dataset all columns ids must be int or str"""
spec, _ = self.create_fixture_dataset_spec(multitable=False, schema=None)
features_table = spec["main_table"][0]
features_table.rename(columns={"User_ID": 1}, inplace=True)
features_table = features_table.rename(columns={"User_ID": 1})
with self.assertRaises(TypeError) as context:
PandasTable(name="reviews", dataframe=features_table)
output_error_msg = str(context.exception)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_estimator_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ def test_regressor_attributes_multitable(self):
"""
X, _ = self._create_multitable_input(750)
y = X["main_table"][0]["Commune"]
X["main_table"][0].drop("Commune", axis=1, inplace=True)
X["main_table"] = (
X["main_table"][0].drop("Commune", axis=1),
X["main_table"][1],
)
khr_accidents = KhiopsRegressor(n_trees=0, n_text_features=0)
with warnings.catch_warnings():
warnings.filterwarnings(
Expand Down
Loading