Skip to content
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

Series lose nullable integer dtype after call to .diff() #30889

Closed
mwaskom opened this issue Jan 10, 2020 · 3 comments · Fixed by #31025
Closed

Series lose nullable integer dtype after call to .diff() #30889

mwaskom opened this issue Jan 10, 2020 · 3 comments · Fixed by #31025
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff ExtensionArray Extending pandas with custom dtypes or arrays.
Milestone

Comments

@mwaskom
Copy link
Contributor

mwaskom commented Jan 10, 2020

c.f. #28285

Code Sample, a copy-pastable example if possible

pd.Series([1, 2, 3], dtype="Int16").diff()
0    NaN
1      1
2      1
dtype: object

Problem description

Output dtype becomes object.

Expected Output

Output dtype remains Int16Dtype.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-42-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.2
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 44.0.0.post20200102
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
xarray : 0.14.1
xlrd : None
xlwt : None
xlsxwriter : None

@TomAugspurger
Copy link
Contributor

Thanks for the report. Confirmed on master.

@TomAugspurger TomAugspurger added this to the 1.0.0 milestone Jan 10, 2020
@jorisvandenbossche jorisvandenbossche added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff ExtensionArray Extending pandas with custom dtypes or arrays. labels Jan 12, 2020
@TomAugspurger
Copy link
Contributor

@jorisvandenbossche are you comfortable with me tagging this for 1.0? I think it's close enough to the NA work to include it, but I could also see it going in a 1.0.1.

@jorisvandenbossche
Copy link
Member

but I could also see it going in a 1.0.1.

Do you mean 1.1? Otherwise I would rather do 1.0.0 instead of 1.1

I have the feeling it is a rather safe fix, and would indeed be nice to have this working on the EAs / nullable integer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
3 participants