Skip to content

TST: Nan must not be converted to string using .loc #45695

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 6 commits into from
Feb 3, 2022

Conversation

NumberPiOso
Copy link
Contributor

@NumberPiOso NumberPiOso changed the title TST: Nan must not be converted to string TST: Nan must not be converted to string using .loc Jan 29, 2022
@@ -43,6 +43,15 @@
from pandas.tests.indexing.common import Base


def test_not_change_nan_loc():
Copy link
Member

Choose a reason for hiding this comment

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

Could you also add a separate test function for the df = pd.DataFrame({'A': [np.nan, np.nan, 'b']}) case in the issue as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Could you use pytest.mark.parameterize to turn this into 1 test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Jan 30, 2022
@NumberPiOso NumberPiOso requested a review from mroeschke February 2, 2022 18:30
@NumberPiOso
Copy link
Contributor Author

ci checks are failing,
however error seems unrelated

Run ci/code_checks.sh typing
mypy --version
mypy 0.931
Performing static analysis using mypy
pandas/core/internals/blocks.py:1142: error: Argument 1 to "np_can_hold_element" has incompatible type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"  [arg-type]

Running mypy at the file confirm the error, and the CI yields an even more errors.

> mypy  pandas/core/internals/blocks.py
pandas/core/internals/blocks.py:389: error: Unused "type: ignore" comment
pandas/core/internals/blocks.py:1142: error: Argument 1 to "np_can_hold_element" has incompatible type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)
> ./ci/code_checks.sh typing
mypy --version
mypy 0.930
Performing static analysis using mypy
pandas/core/internals/ops.py:128: error: No overload variant of "__getitem__" of "ExtensionArray" matches argument type "Tuple[int, slice]"  [call-overload]
...
pandas/core/internals/blocks.py:389: error: Unused "type: ignore" comment
pandas/core/internals/blocks.py:1142: error: Argument 1 to "np_can_hold_element" has incompatible type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"  [arg-type]
...
Performing static analysis using mypy DONE

Should a new Issue about this be added? I would happily work on that

@mroeschke
Copy link
Member

ci checks are failing, however error seems unrelated

Run ci/code_checks.sh typing
mypy --version
mypy 0.931
Performing static analysis using mypy
pandas/core/internals/blocks.py:1142: error: Argument 1 to "np_can_hold_element" has incompatible type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"  [arg-type]

Running mypy at the file confirm the error, and the CI yields an even more errors.

> mypy  pandas/core/internals/blocks.py
pandas/core/internals/blocks.py:389: error: Unused "type: ignore" comment
pandas/core/internals/blocks.py:1142: error: Argument 1 to "np_can_hold_element" has incompatible type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)
> ./ci/code_checks.sh typing
mypy --version
mypy 0.930
Performing static analysis using mypy
pandas/core/internals/ops.py:128: error: No overload variant of "__getitem__" of "ExtensionArray" matches argument type "Tuple[int, slice]"  [call-overload]
...
pandas/core/internals/blocks.py:389: error: Unused "type: ignore" comment
pandas/core/internals/blocks.py:1142: error: Argument 1 to "np_can_hold_element" has incompatible type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"  [arg-type]
...
Performing static analysis using mypy DONE

Should a new Issue about this be added? I would happily work on that

Yup this is unrelated. Looks like it originated from #45792 cc @jbrockmendel
Would be happy to take a fix for it unless it's already being addressed in the meantime.

@mroeschke mroeschke added this to the 1.5 milestone Feb 3, 2022
@mroeschke mroeschke merged commit 3034cfb into pandas-dev:main Feb 3, 2022
@mroeschke
Copy link
Member

Thanks for all your work closing these regression tests @NumberPiOso! Happy to have more!

phofl pushed a commit to phofl/pandas that referenced this pull request Feb 14, 2022
* TST: Nan must not be converted to string

Closes pandas-dev#28403

* TST: Add test specific to the issue  pandas-dev#28403

* TST: Parametrize multiple inputs change nan loc
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
* TST: Nan must not be converted to string

Closes pandas-dev#28403

* TST: Add test specific to the issue  pandas-dev#28403

* TST: Parametrize multiple inputs change nan loc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NaN is converted to strings when reassigning a column with .loc
2 participants