-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: inconsistent upcasting dtypes between diff and shift for int8/int16 #45562
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
Comments
It looks like the diff upcasting to f32 is done here: pandas/pandas/core/algorithms.py Lines 1605 to 1613 in 2db3b0a
and the docstring for that function actually mentions diff and shift: pandas/pandas/core/algorithms.py Lines 1543 to 1546 in 2db3b0a
|
Sidenote: "diff" and "shift" are not aggregations, and so calling them in In [80]: pd.Series([1, 2, 3], dtype="int8")
Out[80]:
0 1
1 2
2 3
dtype: int8
In [81]: pd.Series([1, 2, 3], dtype="int8").agg(["diff", "shift"])
Out[81]:
diff shift
0 NaN NaN
1 1.0 1.0
2 1.0 2.0 |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
It appears diff and shift have inconsistent upcasting of types when the input is either int8 or int16:
Its possible there is good reason for this, but I couldn't find it documented or explained anywhere.
Expected Behavior
More consistency in upcasting between diff and shift.
Installed Versions
INSTALLED VERSIONS
commit : a221491
python : 3.8.12.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.17134
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 1.5.0.dev0+133.ga221491f99.dirty
numpy : 1.21.5
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 60.5.0
Cython : 0.29.26
pytest : 6.2.5
hypothesis : 6.35.0
sphinx : 4.3.2
blosc : None
feather : None
xlsxwriter : 3.0.2
lxml.etree : 4.7.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.0.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : 1.3.2
fastparquet : 0.7.2
fsspec : 2021.11.0
gcsfs : 2021.11.0
matplotlib : 3.5.1
numba : 0.55.0
numexpr : 2.8.0
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 6.0.1
pyreadstat : 1.1.4
pyxlsb : None
s3fs : 2021.11.0
scipy : 1.7.3
sqlalchemy : 1.4.29
tables : 3.6.1
tabulate : 0.8.9
xarray : 0.18.2
xlrd : 2.0.1
xlwt : 1.3.0
zstandard : None
The text was updated successfully, but these errors were encountered: