Closed
Description
mypy error: pandas\core\sparse\frame.py:94:25: error: Item "SparseArray" of "Union[SparseSeries, SparseArray]" has no attribute "index"
Code Sample, a copy-pastable example if possible
>>> import pandas as pd
>>> pd.__version__
'0.25.0+332.g261c3a667'
>>> sa = pd.SparseArray([1,2,3])
>>> sa
[1, 2, 3]
Fill: 0
IntIndex
Indices: array([0, 1, 2])
>>> pd.DataFrame(sa)
0
0 1
1 2
2 3
>>> pd.SparseDataFrame(sa)
__main__: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.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\sparse\frame.py", line 94, in __init__
index = data.index
AttributeError: 'SparseArray' object has no attribute 'index'
>>>
Problem description
The docstring for SparseDataFrame states that the types accepted for the data argument of the constructor are the same types as can be passed to DataFrame.
the DataFrame constructor accepts a SparseArray, the SparseDataFrame constructor raises AttributeError: 'SparseArray' object has no attribute 'index'