Skip to content

Deprecation warning for SparseDataFrame shown for repr / every operation #26555

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

If you are still using the SparseDataFrame class, the warnings are quite sticky:

In [5]: sparse_df = pd.SparseDataFrame(np.array([[1,2, np.nan], [np.nan, 5, 6]]), columns=['a','b','c'])
/home/joris/miniconda3/envs/dev37/bin/ipython:1: FutureWarning: SparseDataFrame is deprecated and will be removed in a future version.
Use a regular DataFrame whose columns are SparseArrays instead.

See http://pandas.pydata.org/pandas-docs/stable/user_guide/sparse.html#migrating for more.

  #!/home/joris/miniconda3/envs/dev37/bin/python

In [6]: sparse_df                                      
Out[6]: /home/joris/scipy/pandas/pandas/core/frame.py:3337: FutureWarning: SparseSeries is deprecated and will be removed in a future version.
Use a Series with sparse values instead.

    >>> series = pd.Series(pd.SparseArray(...))

See http://pandas.pydata.org/pandas-docs/stable/user_guide/sparse.html#migrating for more.

  return klass(values, index=self.index, name=items, fastpath=True)

     a    b    c
0  1.0  2.0  NaN
1  NaN  5.0  6.0

In [7]: sparse_df + 1                               
/home/joris/scipy/pandas/pandas/core/frame.py:3337: FutureWarning: SparseSeries is deprecated and will be removed in a future version.
Use a Series with sparse values instead.

    >>> series = pd.Series(pd.SparseArray(...))

See http://pandas.pydata.org/pandas-docs/stable/user_guide/sparse.html#migrating for more.

  return klass(values, index=self.index, name=items, fastpath=True)
/home/joris/scipy/pandas/pandas/core/ops.py:2304: FutureWarning: SparseSeries is deprecated and will be removed in a future version.
Use a Series with sparse values instead.

    >>> series = pd.Series(pd.SparseArray(...))

See http://pandas.pydata.org/pandas-docs/stable/user_guide/sparse.html#migrating for more.

  name=self.name)
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:298: FutureWarning: SparseDataFrame is deprecated and will be removed in a future version.
Use a regular DataFrame whose columns are SparseArrays instead.

See http://pandas.pydata.org/pandas-docs/stable/user_guide/sparse.html#migrating for more.

  default_fill_value=self.default_fill_value).__finalize__(self)
Out[7]: 
     a    b    c
0  2.0  3.0  NaN
1  NaN  6.0  7.0

So they are also raised each time you display them (repr), on each operation (like the addition I did).

I know users can filter them, but ideally they would be shown a bit less I think to not annoy users too much.

cc @TomAugspurger

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasSparseSparse Data Type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions