We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
s1=pd.Series([True,False,True,True]) s2=pd.Series([True,True,False]) s1.index=pd.MultiIndex.from_tuples( [(0, 2), (1, 1), (1, 2), (2, 1)],names=['st', 'at']) s2.index=pd.Index([0,1,2], name='st') ds1=pd.DataFrame(s1) ds2=pd.DataFrame(s2) s3=pd.Series([True,False,True]) s4=pd.Series([True,True,False])
st at 0 2 True 1 1 False 1 2 True 2 1 False dtype: bool
For series, * and & give different result:
*
&
In: s1 & s2 Out: st at 0 2 False 1 1 False 1 2 False 2 1 False dtype: bool In: s1 * s2 Out: st at 0 2 True 1 1 False 1 2 True 2 1 False dtype: bool
BUT for dataframes they give the same:
In: ds1 * ds2 Out: 0 st at 0 2 True 1 1 False 1 2 True 2 1 False In: ds1 & ds2 Out: 0 st at 0 2 True 1 1 False 1 2 True 2 1 False
and last for series with single index, also both s3 & s4 or s3 * s4 give:
s3 & s4
s3 * s4
0 True 1 False 2 False dtype: bool
pd.show_versions()
pandas: 0.18.1
The text was updated successfully, but these errors were encountered:
It seems there is going something wrong with the alignment.
Also, if you switch the position, you get an error:
In [43]: s2 & s1 ... ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long long'
Sorry, something went wrong.
this is a duplicate of #1134
you need to join before you do this - it's not s well defined operation as specified
I think it is a slightly different issue
Consider those serieses:
In [84]: s1 = pd.Series([True,False,True]) In [85]: s2 = pd.Series([True,True,False]) In [86]: s2b = pd.Series([True,True,False], index=[1,2,3])
The issue in #1134 is that the index is ignored, so using s2 or s2b gives the same:
In [87]: s1 == s2 Out[87]: 0 True 1 False 2 False dtype: bool In [88]: s1 == s2b Out[88]: 0 True 1 False 2 False dtype: bool
But in this case, s2 and s2b do not give the same:
In [89]: s1 & s2 Out[89]: 0 True 1 False 2 False dtype: bool In [90]: s1 & s2b Out[90]: 0 False 1 False 2 True dtype: bool
In the case of non-identical index, the result is also not the same as when the index is ignored:
In [91]: s1.values & s2b.values Out[91]: array([ True, False, False], dtype=bool)
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
Code Sample, a copy-pastable example if possible
Expected Output
For series,
*
and&
give different result:BUT for dataframes they give the same:
and last for series with single index, also both
s3 & s4
ors3 * s4
give:output of
pd.show_versions()
pandas: 0.18.1
The text was updated successfully, but these errors were encountered: