-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Column level names lost when constructing DataFrame
#13740
Comments
Possibly like so: diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py
index 0fe8949090..318f66b62c 100644
--- a/python/cudf/cudf/core/dataframe.py
+++ b/python/cudf/cudf/core/dataframe.py
@@ -722,6 +722,10 @@ class DataFrame(IndexedFrame, Serializable, GetAttrGetItemMixin):
if dtype:
self._data = self.astype(dtype)._data
+ # Fix up
+ if isinstance(columns, pd.MultiIndex):
+ self._data.multiindex = True
+ self._data._level_names = tuple(columns.names)
@_cudf_nvtx_annotate
def _init_from_series_list(self, data, columns, index): This is inappropriate intimacy, so is not a good fix. The issue with the |
Something to note, this is an issue with regular Index in various code-flows. I have a PR coming up soon to cover them |
This PR preserves column names in various APIs by retaining `self._data._level_names` and also calculating when to preserve the column names. Fixes: #13741, #13740 Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Bradley Dice (https://github.com/bdice) - Ashwin Srinath (https://github.com/shwina) - Lawrence Mitchell (https://github.com/wence-) URL: #13772
Fixed by #13772 |
When passing a
MultIiIndex
with level names as thecolumns=
argument to aDataFrame
, the level names are lost:Output:
The text was updated successfully, but these errors were encountered: