Skip to content

BUG: unexpected strange behaviour with pandas and numpy compatibility #47054

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

Closed
2 of 3 tasks
moroclash opened this issue May 18, 2022 · 1 comment
Closed
2 of 3 tasks

Comments

@moroclash
Copy link

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

import pandas as pd
import numpy as np

arr = [np.array([[196]], dtype=np.uint8)] * 100
arr = [i.flat[0] for i in arr]

print(arr[:5])
col = pd.DataFrame(data={"c1": arr })

print(col.head())

Issue Description

this produces a list of-60, actually, any number less than 127 will still be as is, but above that, it changes to a negative number, so any number will be in that range 1 to 127, and if larger than 127 it becomes within that range -1 to 127.

Expected Behavior

this should produce a list of 195s but that has not happened.

Installed Versions

INSTALLED VERSIONS

commit : 66e3805
python : 3.7.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-89-generic
Version : #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.3.5
numpy : 1.21.5
pytz : 2019.1
dateutil : 2.8.0
pip : 22.0.3
setuptools : 59.8.0
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.11.3
IPython : 7.32.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : 1.2.1
fsspec : 2022.02.0
fastparquet : None
gcsfs : 2022.02.0
matplotlib : 3.1.0
numexpr : 2.6.9
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 7.0.0
pyxlsb : None
s3fs : None
scipy : 1.3.0
sqlalchemy : 1.4.31
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.55.1

@moroclash moroclash added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 18, 2022
@jreback
Copy link
Contributor

jreback commented May 18, 2022

uint8 max range is 128 and this is the default behavior to overflow

you have to be extremely careful with small dtypes like this

@jreback jreback added this to the No action milestone May 18, 2022
@jreback jreback added Usage Question and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 18, 2022
@jreback jreback closed this as completed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants