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

Support __invert__ (unary ~) in DataFrame #2110

Closed
jreback opened this issue Oct 24, 2012 · 0 comments
Closed

Support __invert__ (unary ~) in DataFrame #2110

jreback opened this issue Oct 24, 2012 · 0 comments
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Oct 24, 2012

import pandas
import numpy as np

index = pandas.date_range('1/1/2000',periods=8,)
columns = ['A','B','C','D']
df = pandas.DataFrame(np.random.randn(len(index),len(columns)),index=index
printdf
A B C D
2000-01-01 0.752832 0.083465-0.273210 1.128781
2000-01-02 0.895254 0.401056 1.473770 1.998924
2000-01-03 2.318820 0.384354-1.056422-1.280257
2000-01-04 0.981042 0.717762-1.015285-1.146636
2000-01-05-0.979061-1.765188 0.025436-0.815622
2000-01-06-0.166251 1.887524-0.131171-0.802795
2000-01-07 0.025936 0.122587 0.517295 0.589679
2000-01-08 0.691059 0.458683-0.856201-0.412374

s = pandas.Series(np.random.randn(len(index)),index=index)
print s

2000-01-01 -0.182340
2000-01-02 0.031729
2000-01-03 0.616713
2000-01-04 -0.329961
2000-01-05 -1.220345
2000-01-06 -1.323948
2000-01-07 1.182522
2000-01-08 -0.622332

__invert__ works in Series (the ~ operator)
but not in DataFrame

print s[~(s<0)]
print ~(df<0)

2000-01-02 0.031729
2000-01-03 0.616713
2000-01-07 1.182522
TypeError: bad operand type for unary~: 'DataFrame'
changhiskhan added a commit that referenced this issue Nov 1, 2012
@wesm wesm closed this as completed Nov 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants