Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TST: add fillna test for filling with Categorical #62319

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

Open
thaiv28 wants to merge 3 commits into pandas-dev:main
base: main
Choose a base branch
Loading
from thaiv28:test-fillna

Conversation

Copy link

@thaiv28 thaiv28 commented Sep 11, 2025
edited
Loading

Added a test to TestFillNA to check that call fillna with a Series of dtype Categorical does not throw an error.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

)

filler = Series(Categorical([10.0, 20.0, 30.0]))
df.fillna({"ints": filler}, inplace=True)
Copy link
Member

@rhshadrach rhshadrach Sep 30, 2025

Choose a reason for hiding this comment

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

Can you avoid mutating here; when debugging, it can be helpful to have both before and after the operation accessible.

Suggested change
df.fillna({"ints": filler}, inplace=True)
result=df.fillna({"ints": filler})

tm.assert_frame_equal(df.fillna(value=NaT), df)

def test_fillna_with_categorical_series(self):
df = DataFrame(
Copy link
Member

@rhshadrach rhshadrach Sep 30, 2025

Choose a reason for hiding this comment

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

Add a reference to the issue as a comment on the first line.

# https://github.com/pandas-dev/pandas/issues/56329

@rhshadrach rhshadrach added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Needs Tests Unit test(s) needed to prevent regressions Categorical Categorical Data Type labels Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@rhshadrach rhshadrach rhshadrach requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
Categorical Categorical Data Type Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

BUG: AssertionError: Did not expect new dtype float64 to equal self.dtype float64. Please report a bug

AltStyle によって変換されたページ (->オリジナル) /