From 65ffe9d81fbc0349a88db2fb2cc7ee8c8b56f6d3 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 17 Mar 2024 15:04:20 +0200 Subject: [PATCH] Fix pandas DataFrame artifacts with hierarchical indices get mangled by the CSV roundtrip --- clearml/binding/artifacts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clearml/binding/artifacts.py b/clearml/binding/artifacts.py index 99d02668..4874ae5a 100644 --- a/clearml/binding/artifacts.py +++ b/clearml/binding/artifacts.py @@ -464,6 +464,10 @@ class Artifacts(object): artifact_type_data.content_type = "text/csv" np.savetxt(local_filename, artifact_object, delimiter=",") delete_after_upload = True + elif pd and isinstance(artifact_object, pd.DataFrame) \ + and (isinstance(artifact_object.index, pd.MultiIndex) or + isinstance(artifact_object.columns, pd.MultiIndex)): + store_as_pickle = True elif pd and isinstance(artifact_object, pd.DataFrame): artifact_type = "pandas" artifact_type_data.preview = preview or str(artifact_object.__repr__())