Skip to content

[question] possible to use compound logic in indexing #87

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

Closed
reckoner opened this issue Aug 1, 2011 · 1 comment
Closed

[question] possible to use compound logic in indexing #87

reckoner opened this issue Aug 1, 2011 · 1 comment

Comments

@reckoner
Copy link

reckoner commented Aug 1, 2011

in your documentation, you have the following example:

  >>> df[df['A'] > 0.5]
                         A              D              N              S
  2009-05-29 00:00:00    0.979307       0.979307       4              5
  2009-07-31 00:00:00    0.536261       nan            6              5
  2009-09-30 00:00:00    0.537841       nan            8              5

would it be possible to do something like this:

  >>> df[df['A'] > 0.5 and df['N']>5] 

where both conditions are satisfied? The syntax supports it, but I'm not getting what I expect.

@wesm
Copy link
Member

wesm commented Aug 7, 2011

"and" can't be used with numpy arrays, you have to use an ampersand: &

df[(df['A'] > 0.5) & (df['N']>5)] 

you need the parentheses so the expression gets parsed correctly

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

No branches or pull requests

2 participants