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

BUG: pd.NA showing up as NaN in Categorical repr #52681

Closed
wants to merge 3 commits into from

Conversation

lithomas1
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@lithomas1 lithomas1 added Bug Categorical Categorical Data Type labels Apr 15, 2023
@lithomas1 lithomas1 marked this pull request as ready for review April 15, 2023 12:20
@lithomas1 lithomas1 added the Output-Formatting __repr__ of pandas objects, to_string label Apr 15, 2023
@topper-123
Copy link
Contributor

I have been thinking about a change to the use of the na value in Categorical, and just wrote up #52687 after being reminded by this PR. This would also change the repr IMO as a consequence of the change, so I think that would make this PR unnecessary,.

@lithomas1
Copy link
Member Author

Sure, happy to see what you got.

Feel free to take my test(or any parts of this PR) if you need it.

def test_categorical_repr_nullable_int_NA(self, values_dtype):
arr = array([1, 2, np.nan], dtype=values_dtype)
c = Categorical(arr)
c_exp = f"""[1, 2, {NA}]\nCategories (2, {values_dtype}): [1, 2]"""
Copy link
Member

Choose a reason for hiding this comment

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

so if you did c[2] would you get pd.NA or np.nan? i'm wary of changing the repr without changing the item

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label May 22, 2023
@mroeschke
Copy link
Member

Looks like this has gone stale. Closing to clear the queue but feel free to reopen if you want to continue

@mroeschke mroeschke closed this Jun 1, 2023
@topper-123
Copy link
Contributor

FYI, there is a slightly related #53190, which isn’t getting traction though…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Output-Formatting __repr__ of pandas objects, to_string Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants