Skip to content

v0.15.1 breaks index set operations #9095

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

In 0.15.0, the - index set operation raises a warning as is explained in the whatsnew docs: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#deprecations

In [1]: pd.__version__
Out[1]: '0.15.0'

In [2]: idx = pd.Index([1,2])

In [3]: idx
Out[3]: Int64Index([1, 2], dtype='int64')

In [4]: idx - idx
C:\Anaconda\envs\pandas0150\lib\site-packages\pandas\core\index.py:1162: FutureW
arning: using '-' to provide set differences with Indexes is deprecated, use .di
fference()
  "use .difference()",FutureWarning)
Out[4]: Index([], dtype='object')

In [6]: idx = pd.date_range('2012-01-01', periods=2)

In [7]: idx - idx
Out[7]: Index([], dtype='object')

In [8]: idx = pd.Index([1.1,2])

In [10]: idx
Out[10]: Float64Index([1.1, 2.0], dtype='float64')

In [11]: idx - idx
Out[11]: Index([], dtype='object')

In [12]: idx = pd.Index(['a', 'b'])

In [13]: idx - idx
Out[13]: Index([], dtype='object')

But in 0.15.1:

In [1]: pd.__version__
Out[1]: '0.15.1'

In [2]: idx = pd.Index([1,2])

In [3]: idx
Out[3]: Int64Index([1, 2], dtype='int64')

In [4]: idx - idx
Out[4]: Int64Index([0, 0], dtype='int64')

In [5]: idx = pd.date_range('2012-01-01', periods=2)

In [6]: idx - idx
Out[6]: Index([], dtype='object')

In [7]: idx = pd.Index([1.1,2])

In [8]: idx - idx
Out[8]: Float64Index([0.0, 0.0], dtype='float64')

In [9]: idx = pd.Index(['a', 'b'])

In [10]: idx - idx
pandas\core\index.py:1172: FutureWarning: using '-' to provide set differences w
ith Indexes is deprecated, use .difference()
  "use .difference()",FutureWarning)
Out[10]: Index([], dtype='object')

So

  • for int/float index, it is a numeric operation and not set -> api break
  • for datetime it is set operation, but does not raise a warning
  • only for object (Index object itself) it raises the warning

And the same on master (and 0.15.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions