Skip to content

BUG: GH3311 Dataframe where with a datetimelike was not correctly selecting #3312

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 1 commit into from
Apr 10, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Apr 10, 2013

closes #3311

jreback added a commit that referenced this pull request Apr 10, 2013
BUG: GH3311 Dataframe where with a datetimelike was not correctly selecting
@jreback jreback merged commit 5ea9d01 into pandas-dev:master Apr 10, 2013
@jbrockmendel
Copy link
Member

@jreback I think this PR introduced some behavior (definitely codified it in a test) that is incorrect. From the test:

        df = DataFrame(dict(A = date_range('20130102',periods=5), 
                            B = date_range('20130104',periods=5),
                            C = np.random.randn(5)))

        stamp = datetime(2013,1,3)
        result = df[df > stamp]

But if you just look at the df > stamp:

>>> df > stamp
       A     B     C
0  False  True  True
1  False  True  True
2   True  True  True
3   True  True  True
4   True  True  True

Consistency with Series, Index, and scalars would require comparison with the "C" column to raise TypeError. Also the reverse inequality also comes back as all-True for the "C" column:

>>> df < stamp
       A      B     C
0   True  False  True
1  False  False  True
2  False  False  True
3  False  False  True
4  False  False  True

So the question: OK to make this raise? Or is there a compelling reason for this to be different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: datetime selection in a DataFrame should work in the where
2 participants