-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST: Add test for where inplace #44255
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
TST: Add test for where inplace #44255
Conversation
This adds a test for `where` to ensure that None-to-NaN casting behaves the same both when `inplace=True` and otherwise.
@@ -787,3 +791,30 @@ def test_where_columns_casting(): | |||
result = df.where(pd.notnull(df), None) | |||
# make sure dtypes don't change | |||
tm.assert_frame_equal(expected, result) | |||
|
|||
|
|||
optional_ints = st.lists(st.one_of(st.integers(), st.none()), max_size=10, min_size=3) |
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.
ideally would want to add lots of other things here, e.g. datetetimes (naive & tz-aware), timedelta, categorical, period, interval. (can be a followup)
also would be better to centralize some of this hypothesis type generation. (do this in this PR)
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.
thanks request to move some things around
pandas/tests/frame/common.py
Outdated
@@ -56,3 +58,18 @@ def zip_frames(frames: list[DataFrame], axis: int = 1) -> DataFrame: | |||
index = frames[0].index | |||
zipped = [f.loc[i, :] for i in index for f in frames] | |||
return DataFrame(zipped) | |||
|
|||
|
|||
OPTIONAL_INTS = st.lists(st.one_of(st.integers(), st.none()), max_size=10, min_size=3) |
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 these to pandas/_testing/_hypothesis.py
we also have these
pandas/tests/io/parser/test_parse_dates.py:from hypothesis import (
pandas/tests/io/parser/test_parse_dates.py:# Strategy for hypothesis
pandas/tests/io/parser/test_parse_dates.py:def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
pandas/tests/io/parser/test_parse_dates.py:def test_hypothesis_delimited_date(date_format, dayfirst, delimiter, test_datetime):
pandas/tests/io/parser/test_parse_dates.py: except_out_dateutil, result = _helper_hypothesis_delimited_date(
pandas/tests/io/parser/test_parse_dates.py: except_in_dateutil, expected = _helper_hypothesis_delimited_date(
pandas/tests/tslibs/test_ccalendar.py:from hypothesis import (
pandas/tests/tseries/offsets/test_ticks.py:from hypothesis import (
pandas/tests/tseries/offsets/test_offsets_properties.py:from hypothesis import (
pandas/tests/tseries/offsets/test_offsets_properties.py:from hypothesis.errors import Flaky
pandas/tests/tseries/offsets/test_offsets_properties.py:from hypothesis.extra.dateutil import timezones as dateutil_timezones
pandas/tests/tseries/offsets/test_offsets_properties.py:from hypothesis.extra.pytz import timezones as pytz_timezones
pandas/tests/tseries/offsets/test_offsets_properties.py: # indicate to hypothesis that this is not a valid test case
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.
e.g. any creation routines i want to move.
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.
@jreback Just want to make sure I'm clear on what you're asking for here. In addition to the helpers I added, you're asking me to move all hypothesis helpers into that proposed new _hypothesis.py
testing module?
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 @rlvoyer |
This adds a test for ensuring that None-to-NaN type-casting is consistent with
where
wheninplace=True
and otherwise.