Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply metadata to keys before returning in
Frame._encode
(#8560)
Fixes #7365 Applies column metadata to the output columns of `keys` in `Frame._encode`; skipping this step meant that the output of `DataFrame.unstack` would not have the expected metadata for index columns: ```python import pandas as pd import cudf pdf = pd.DataFrame( { "foo": ["one", "one", "one", "two", "two", "two"], "bar": pd.Categorical(["A", "B", "C", "A", "B", "C"]), "baz": [1, 2, 3, 4, 5, 6], "zoo": ["x", "y", "z", "q", "w", "t"], }).set_index(["foo", "bar", "baz"]) gdf = cudf.from_pandas(pdf) pdf.unstack("baz") zoo baz 1 2 3 4 5 6 foo bar one A x NaN NaN NaN NaN NaN B NaN y NaN NaN NaN NaN C NaN NaN z NaN NaN NaN two A NaN NaN NaN q NaN NaN B NaN NaN NaN NaN w NaN C NaN NaN NaN NaN NaN t gdf.unstack("baz") zoo baz 1 2 3 4 5 6 foo bar one 0 x <NA> <NA> <NA> <NA> <NA> 1 <NA> y <NA> <NA> <NA> <NA> 2 <NA> <NA> z <NA> <NA> <NA> two 0 <NA> <NA> <NA> q <NA> <NA> 1 <NA> <NA> <NA> <NA> w <NA> 2 <NA> <NA> <NA> <NA> <NA> t ``` Authors: - Charles Blackmon-Luca (https://github.com/charlesbluca) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: #8560
- Loading branch information