Skip to content
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

Fix DataFrame.reindex removing column name #14601

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

mroeschke
Copy link
Contributor

Description

Fixes the following behavior

In [1]: import cudf
    
In [2]: import pandas as pd

In [3]: df = cudf.DataFrame([1], columns=cudf.Index([1], name="foo"))

In [4]: df
Out[4]: 
foo  1
0    1

In [5]: df = df.reindex(index=[0, 1])

In [6]: df
Out[6]: 
      1  <-- foo missing
0     1
1  <NA>

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added bug Something isn't working Python Affects Python cuDF API. non-breaking Non-breaking change labels Dec 8, 2023
@mroeschke mroeschke requested a review from a team as a code owner December 8, 2023 21:05
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same pattern appears here. Is it also problematic?

level_names=tuple(columns.names)
if isinstance(columns, pd.Index)
else None,

@mroeschke
Copy link
Contributor Author

The same pattern appears here. Is it also problematic?

I think this one is OK. Since this is in __init__, for this data=None branch there is no data column name to preserve

@mroeschke
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 8c511d1 into rapidsai:branch-24.02 Dec 8, 2023
68 checks passed
@mroeschke mroeschke deleted the bug/reindex/col_name branch December 8, 2023 23:15
karthikeyann pushed a commit to karthikeyann/cudf that referenced this pull request Dec 12, 2023
Fixes the following behavior

```python
In [1]: import cudf
    
In [2]: import pandas as pd

In [3]: df = cudf.DataFrame([1], columns=cudf.Index([1], name="foo"))

In [4]: df
Out[4]: 
foo  1
0    1

In [5]: df = df.reindex(index=[0, 1])

In [6]: df
Out[6]: 
      1  <-- foo missing
0     1
1  <NA>
```

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: rapidsai#14601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants