Skip to content

No deprecation warning raised for index - list operation #10038

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

Ilustration:

idx = pd.Index(['a', 'b', 'c', 'd'])
idx - ['a', 'd']
idx - pd.Index(['a', 'd'])

gives:

In [1]: idx = pd.Index(['a', 'b', 'c', 'd'])

In [2]: idx - ['a', 'd']
Out[2]: Index([u'b', u'c'], dtype='object')

In [3]: idx - pd.Index(['a', 'd'])
c:\users\vdbosscj\scipy\pandas-joris\pandas\core\index.py:1192: FutureWarning: u
sing '-' to provide set differences with Indexes is deprecated, use .difference(
)
  "use .difference()",FutureWarning)
Out[3]: Index([u'b', u'c'], dtype='object')

So a list is treated a an index-like (as it performs a set operation), but does not raise a warning as it should (the same for arrays, series).

We have an occurrence in the docs of this one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDeprecateFunctionality to remove in pandasIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions