Skip to content

Add new test for None values on string columns on a Dataframe #52523

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

Merged
merged 3 commits into from
Apr 10, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def test_not_change_nan_loc(series, new_series, expected_ser):


class TestLoc:
def test_none_values_on_string_columns(self):
# Issue #32218
data = {"a": ["1", "2", None]}
df = DataFrame(data=data, dtype="str")
Copy link
Member

Choose a reason for hiding this comment

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

From the issue df = pd.DataFrame(["1", "2", None], columns=["a"], dtype="str") should be the DataFrame being tested here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pre-commit check fails if i write pd.Dataframe, is it ok to write Dataframe instead?

Copy link
Member

Choose a reason for hiding this comment

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

Yes


assert df.loc[2, "a"] is None

@pytest.mark.parametrize("kind", ["series", "frame"])
def test_loc_getitem_int(self, kind, request):
# int label
Expand Down