-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
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
Sparse dataframe fails when astype() is called with dictionary #26227
Comments
@stefansimik Thanks for the report. after having a quick look at allowing SparseDataFrame.astype to work with a dict, the code sample raises
which i believe is a separate issue, xref #25694.
This is not the case at the moment, SparseDataFrame.astype is implemented independently from DataFrame.astype (which is inherited directly from NDFrame.astype). SparseDataFrame.astype does not have the same signature and does not support copy and errors arguments or the ability to pass kwargs to the constructor either. |
I'd recommend using a DataFrame with sparse values, rather than a SparseDataFrame. Then a regular |
Thanks @TomAugspurger It is quite a big problem to find good explanations and practical examples about how we are expected to use pandas sparse structures. Pandas docs contains just basic content, which is possibly obsolete, as I read around here, that SparseDataFrame is going to be deprecated and to use sparse-dataframes is not recommended approach for the near future... |
Not at the moment, sorry.
… On Apr 29, 2019, at 15:12, stefansimik ***@***.***> wrote:
Thanks @TomAugspurger
Can you please show a few lines of code, what you mean by 'using a DataFrame with sparse values'?
Or do you have any useful links, that elaborate more deeply about using 'sparse' structures in practice?
It is quite a big problem to find good explanations and practical examples about how we are expected to use pandas sparse structures. Pandas docs contains just basic content, which is possibly obsolete, as I read around here, that SparseDataFrame is going to be deprecated and to use them is not recommended approach for the near future...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Code Sample, a copy-pastable example if possible
Problem description
Problem is, that one cannot convert column types when working with sparse-dataframe.
But calling .astype(..) function fails with this error:
Expected Output
It is expected, that what works on dense-dataframe, should also work on sparse-dataframe.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.8.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 79 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.24.1
pytest: None
pip: 19.0.1
setuptools: 40.8.0
Cython: None
numpy: 1.15.4
scipy: 1.2.0
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: