Skip to content
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

BUG: Index.where vs Series.where mismatch #37682

Closed
jbrockmendel opened this issue Nov 7, 2020 · 1 comment · Fixed by #38021 or #38073
Closed

BUG: Index.where vs Series.where mismatch #37682

jbrockmendel opened this issue Nov 7, 2020 · 1 comment · Fixed by #38021 or #38073
Labels
Bug Series Series data structure
Milestone

Comments

@jbrockmendel
Copy link
Member

If in merge._maybe_add_join_keys we replace a call to Index.where with a call to Series.where, we get a test failure because of the following mismatch:

dr = pd.date_range("2001-01-01", periods=3)
lvals = pd.DatetimeIndex([dr[0], dr[1], pd.NaT])._data
rvals = pd.Categorical([dr[0], pd.NaT, dr[2]])

mask = np.array([False, False, True])

>>> pd.Series(lvals).where(~mask, rvals)._values
array([Timestamp('2001-01-01 00:00:00'), Timestamp('2001-01-02 00:00:00'),
       978480000000000000], dtype=object)

>>> pd.Index(lvals).where(~mask, rvals)._values
<DatetimeArray>
['2001-01-01 00:00:00', '2001-01-02 00:00:00', '2001-01-03 00:00:00']
Length: 3, dtype: datetime64[ns]

The Index version looks better behaved. These should share an implementation.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member Series Series data structure and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 7, 2020
@jbrockmendel jbrockmendel reopened this Dec 17, 2020
@jbrockmendel
Copy link
Member Author

Not closed by #38021, will be closed by #38073.

@jreback jreback added this to the 1.3 milestone Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Series Series data structure
Projects
None yet
2 participants