Skip to content

SparseDataFrame(scipy.sparse.matrix) constructor generates lots of warnings #26777

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

cc @TomAugspurger another one ...

Passing a sparse matrix to the SparseDataFrame constructor can generate a flood of warning message (I think because each column of the sparse matrix is converted to a SparseSeries, triggering the warning each time):

In [2]: import scipy.sparse                    

In [3]: sparse = scipy.sparse.rand(10, 10, 0.5) 

In [4]: pd.SparseDataFrame(sparse)                  
/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
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
/home/joris/scipy/pandas/pandas/core/sparse/frame.py:230: 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.

  sparse_index=BlockIndex(N, blocs, blens))
Out[4]: 
          0         1         2         3         4         5         6         7         8         9
0  0.856466  0.482052  0.289636       NaN  0.369485       NaN  0.907167       NaN       NaN  0.531253
1       NaN       NaN  0.305235       NaN       NaN       NaN  0.744132  0.001257       NaN  0.406300
2       NaN       NaN  0.638244       NaN       NaN       NaN  0.436574       NaN       NaN  0.225573
3  0.881299       NaN  0.645047  0.203569       NaN  0.341134       NaN  0.553526  0.539011  0.682595
4  0.481258       NaN       NaN  0.919469       NaN  0.101564       NaN       NaN       NaN       NaN
5  0.244346  0.282246       NaN       NaN       NaN       NaN       NaN       NaN  0.412830       NaN
6  0.051837       NaN  0.101553  0.512826  0.985031  0.679645  0.248445       NaN  0.081652       NaN
7  0.048519       NaN  0.621497  0.483698       NaN       NaN       NaN  0.548918       NaN  0.716907
8       NaN  0.801704       NaN       NaN       NaN  0.611459  0.669670       NaN  0.835271  0.336365
9  0.302106       NaN  0.672587  0.609117  0.570041  0.662911  0.684364       NaN       NaN  0.795059

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasSparseSparse Data Type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions