Skip to content

compare two series objects ignores index #8257

Closed
@longislandfarmer

Description

@longislandfarmer

It seems that when comparing two Series objects, index is ignored, here is an trivial example

In [177]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.7.final.0
python-bits: 64
OS: Linux
OS-release: 3.2.0-0.bpo.4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US

pandas: 0.14.0
nose: 1.3.0
Cython: 0.19.2
numpy: 1.8.1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.0.0
sphinx: 1.1.3
patsy: 0.2.1
scikits.timeseries: None
dateutil: 1.5
pytz: 2014.3
bottleneck: None
tables: 3.0.0
numexpr: 2.2.2
matplotlib: 1.3.1
openpyxl: 1.6.2
xlrd: 0.9.2
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.2.3
bs4: 4.3.1
html5lib: None
bq: None
apiclient: None
rpy2: None
sqlalchemy: 0.8.3
pymysql: None
psycopg2: None


In [158]: a = pd.Series([100, 101, 102, 103], index=[1,2,3,4])
In [168]: b = pd.Series([102, 103, 104, 105], index=[3, 4, 5, 6])

In [170]: a
Out[170]:
1    100
2    101
3    102
4    103
dtype: int64

In [171]: b
Out[171]:
3    102
4    103
5    104
6    105
dtype: int64

In [172]: a > b
Out[172]:
1    False
2    False
3    False
4    False
dtype: bool

In [173]: a < b
Out[173]:
1    True
2    True
3    True
4    True
dtype: bool

In [174]: a == b
Out[174]:
1    False
2    False
3    False
4    False
dtype: bool

In [175]: a - b
Out[175]:
1   NaN
2   NaN
3     0
4     0
5   NaN
6   NaN
dtype: float64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsDocs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions