-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
@@ -2698,6 +2698,14 @@ def test_frame_from_dict_with_mixed_tzaware_indexes(self): | |||
|
|||
|
|||
class TestDataFrameConstructorWithDtypeCoercion: | |||
def test_none_values_on_string_columns(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to pandas/tests/indexing/test_loc.py
in the class TestLoc
class?
@@ -2698,6 +2698,14 @@ def test_frame_from_dict_with_mixed_tzaware_indexes(self): | |||
|
|||
|
|||
class TestDataFrameConstructorWithDtypeCoercion: | |||
def test_none_values_on_string_columns(self): | |||
# Creating DataFrame with column "a" as string and a None value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are not needed. Instead could you add a comment with the github issue number?
df = DataFrame(data=data, dtype="str") | ||
|
||
# Checking that the value of the third row in column "a" is actually None | ||
assert isna(df.loc[2, "a"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert isna(df.loc[2, "a"]) | |
assert df.loc[2, "a"] is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greetings @mroeschke, i made the changes as requested
pandas/tests/indexing/test_loc.py
Outdated
def test_none_values_on_string_columns(self): | ||
# Issue #32218 | ||
data = {"a": ["1", "2", None]} | ||
df = DataFrame(data=data, dtype="str") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Thanks @GrammatikakisDimitris |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Although this issue seems to be gone, i noticed in the comments that a test for this would be appreciated, so this basically checks that Dataframe behaves as it should.