Skip to content

Commit 7cbd63a

Browse files
gustavocidornelaswhoseoyster
authored andcommitted
Fix pandas SettingwithCopyWarning
1 parent 426c2ed commit 7cbd63a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

openlayer/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,14 +1156,17 @@ def _add_default_column(
11561156
) -> Tuple[Dict[str, any], pd.DataFrame]:
11571157
"""Adds the default column specified by ``column_name`` to the dataset config
11581158
and dataframe."""
1159+
df = df.copy()
11591160
if column_name == "timestampColumnName":
11601161
timestamp_column_name = f"timestamp_{str(uuid.uuid1())[:8]}"
11611162
config["timestampColumnName"] = timestamp_column_name
1162-
df[timestamp_column_name] = int(time.time())
1163+
df.loc[:, timestamp_column_name] = int(time.time())
11631164
elif column_name == "inferenceIdColumnName":
11641165
inference_id_column_name = f"inference_id_{str(uuid.uuid1())[:8]}"
11651166
config["inferenceIdColumnName"] = inference_id_column_name
1166-
df[inference_id_column_name] = [str(uuid.uuid1()) for _ in range(len(df))]
1167+
df.loc[:, inference_id_column_name] = [
1168+
str(uuid.uuid1()) for _ in range(len(df))
1169+
]
11671170
return config, df
11681171

11691172
def publish_ground_truths(

0 commit comments

Comments
 (0)