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

BUG: read_parquet unexpected output with pyarrow 0.16.0 and nullable usigned int dtype #31896

Closed
cat-Yu opened this issue Feb 11, 2020 · 1 comment · Fixed by #31918
Closed
Labels
Bug IO Parquet parquet, feather NA - MaskedArrays Related to pd.NA and nullable extension arrays
Milestone

Comments

@cat-Yu
Copy link

cat-Yu commented Feb 11, 2020

data = [np.nan, 1, 2, 3, 4]
df = pd.DataFrame()
df['col'] = pd.Series(data, dtype = "UInt32")
df.to_parquet('example.parquet')
res = pd.read_parquet('example.parquet')
print(res)

Problem description

The above cope prints:

    col
0  <NA>
1     0
2     1
3     0
4     2

This happened after I upgraded to pyarrow 0.16.0, and UInt32 is the only dtype that I had trouble with.
The problem should be with read_parquet, I tried reading parquet with another package, and got the expected output.

Expected Output

    col
0  <NA>
1     1
2     2
3     3
4     4

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.3.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.0.1
numpy : 1.17.3
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.2.0.post20200210
Cython : None
pytest : 5.3.2
hypothesis : None
sphinx : 2.3.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.11.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.2
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pytest : 5.3.2
pyxlsb : None
s3fs : 0.4.0
scipy : 1.4.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : 0.48.0

@jorisvandenbossche jorisvandenbossche added Bug IO Parquet parquet, feather NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Feb 11, 2020
@jorisvandenbossche
Copy link
Member

@cat-Yu Thanks for the report!

So it seems that "uint32" data cannot be stored in parquet, and they are rather stored as int64. When reading back in, pandas still assumes that the data is uint32 (without checking that is actually the case) and thus incorrectly interprets the int64 data as uint32.

@jorisvandenbossche jorisvandenbossche added this to the 1.0.2 milestone Feb 12, 2020
@jorisvandenbossche jorisvandenbossche changed the title read_parquet unexpected output with pyarrow 0.16.0 BUG: read_parquet unexpected output with pyarrow 0.16.0 and nullable usigned int dtype Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Parquet parquet, feather NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants