-
-
Couldn't load subscription status.
- Fork 19.2k
ENH: add sparse op for int64 dtypes #13848
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
Conversation
Current coverage is 85.28% (diff: 98.00%)@@ master #13848 diff @@
==========================================
Files 139 139
Lines 50020 50046 +26
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 42657 42682 +25
- Misses 7363 7364 +1
Partials 0 0
|
|
Haven't had a chance to look through the code yet, but what are the rules around alignment and potentially recasting the dtype? import numpy as np
import pandas as pd
s1 = pd.SparseSeries(np.arange(4), dtype=np.int64, fill_value=0)
s2 = pd.SparseSeries(np.arange(4), index=range(1, 5), dtype=np.int64, fill_value=0)
s1 + s1 # OK
s1 + s2 # errorTraceback (most recent call last):
File "script.py", line 8, in <module>
s1 + s2 # error
File "/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/sparse/series.py", line 56, in wrapper
return _sparse_series_op(self, other, op, name)
File "/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/sparse/series.py", line 81, in _sparse_series_op
series=True)
File "/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/sparse/array.py", line 119, in _sparse_array_op
sparse_op = getattr(splib, opname)
AttributeError: module 'pandas._sparse' has no attribute 'sparse_add_float64' |
|
@TomAugspurger The latter case looks work on my branch, the error seems to show that sparse.pyx is not re-compiled properly. I'm adding more tests related to alignment:) |
|
My bad, just got to that section of the code. Recompiled and it does indeed work 👍 |
doc/source/whatsnew/v0.19.0.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes allow pandas to handle sparse data with more dtypes.
|
rebase in light of changes #13787 |
9f69e99 to
75dfca7
Compare
|
thanks! nice cleanup |
|
FYI: 8ec7406 as we no longer depend on generated; was causing recompilation of algos.pyx every time :< |
|
small dtype adj needed on windows |
|
Thx, will fix. |
git diff upstream/master | flake8 --diffAs a first step for #667, numeric op can now preserve
int64dtype. On current master, dtype is reset tofloat64after op.NOTE:
int64SparseSeries.__floordiv__test is skipped because denseSeriesalso has inconsistency innan/infhandling (#13843). Currently it outputs the same result asfloat64.