Skip to content

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

Merged
merged 8 commits into from
Dec 2, 2021

Conversation

rlvoyer
Copy link
Contributor

@rlvoyer rlvoyer commented Oct 31, 2021

This adds a test for ensuring that None-to-NaN type-casting is consistent with where when inplace=True and otherwise.

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)
Copy link
Contributor

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)

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite labels Nov 1, 2021
@rlvoyer rlvoyer requested a review from jreback November 3, 2021 01:15
Copy link
Contributor

@jreback jreback left a 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

@@ -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)
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

@jreback jreback added this to the 1.4 milestone Nov 5, 2021
@rlvoyer rlvoyer requested a review from jreback December 1, 2021 03:11
@jreback jreback merged commit 9db55a7 into pandas-dev:master Dec 2, 2021
@jreback
Copy link
Contributor

jreback commented Dec 2, 2021

thanks @rlvoyer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

where method results in a different outputs when using the inplace kwarg
2 participants