We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import pandas as pd s = pd.Series([1, 2, 3], name="x") df = pd.concat([s, s**2], axis=1) df = df.astype(pd.SparseDtype("float", fill_value=0)) df.sparse.to_coo()
The above code throws IndexError: 0.
IndexError: 0
This is a problem either because it is an unsupported case but the error message is cryptic or because it is a supported case.
No error is thrown or an exception explaining that columns with identical names are not supported is thrown.
pd.show_versions()
commit : None python : 3.7.5.candidate.1 python-bits : 64 OS : Linux OS-release : 5.3.0-19-generic machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 0.25.3 numpy : 1.17.4 pytz : 2019.3 dateutil : 2.8.1 pip : 19.3.1 setuptools : 41.1.0 Cython : 0.29.14 pytest : None hypothesis : None sphinx : 2.2.1 blosc : None feather : None xlsxwriter : None lxml.etree : 4.4.1 html5lib : 1.0.1 pymysql : None psycopg2 : 2.8.4 (dt dec pq3 ext lo64) jinja2 : 2.10.3 IPython : 7.9.0 pandas_datareader: None bs4 : 4.8.0 bottleneck : None fastparquet : None gcsfs : None lxml.etree : 4.4.1 matplotlib : 3.1.1 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pytables : None s3fs : None scipy : 1.3.2 sqlalchemy : 1.3.11 tables : None xarray : None xlrd : None xlwt : None xlsxwriter : None
The text was updated successfully, but these errors were encountered:
We should pass a list to find_common_type in
find_common_type
> /Users/taugspurger/sandbox/pandas/pandas/core/arrays/sparse/accessor.py(291)to_coo() 289 from scipy.sparse import coo_matrix 290 --> 291 dtype = find_common_type(self._parent.dtypes) 292 if isinstance(dtype, SparseDtype): 293 dtype = dtype.subtype
rather than the Series. So dtype = find_common_type(list(self._parent.dtypes)) may fix it.
dtype = find_common_type(list(self._parent.dtypes))
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
Problem description
The above code throws
IndexError: 0
.This is a problem either because it is an unsupported case but the error message is cryptic or because it is a supported case.
Expected Output
No error is thrown or an exception explaining that columns with identical names are not supported is thrown.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.5.candidate.1
python-bits : 64
OS : Linux
OS-release : 5.3.0-19-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.3
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 41.1.0
Cython : 0.29.14
pytest : None
hypothesis : None
sphinx : 2.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 7.9.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.2
sqlalchemy : 1.3.11
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: