hgrecco / pint-pandas

Pandas support for pint
Other
166 stars 40 forks source link

Broken string representation #229

Closed mflova closed 2 months ago

mflova commented 2 months ago

I am not sure if this is more on the pint side about how the pint array is represented or if it belongs to pint-pandas, but I consider this to be a critical problem as the representation is totally missleading and wrong:

df = pd.DataFrame({"a": [1,2,3], "b": [1,2,3]})
print(df)
"""
   a  b
0  1  1
1  2  2
2  3  3
"""
df = df.astype("pint[rpm]")
print(df)
"""
0
1  a  b
2  1  1
"""

This problem seems to be present whenever a pint data (with multiple values) needs to be displayed. Therefore, printing after an aggregation based method is performed is also broken. I also tested with MultiIndex in both index and columns and also broken

andrewgsavage commented 2 months ago

what versions are you using? tis works fine for me

pint_pandas.show_versions()
{'numpy': '1.25.2',
 'pandas': '2.1.0',
 'pint': '0.23',
 'pint_pandas': '0.6.dev6+g2e087e6'}
df = pd.DataFrame({"a": [1,2,3], "b": [1,2,3]})
print(df)
   a  b
0  1  1
1  2  2
2  3  3
df = df.astype("pint[rpm]")
print(df)
   a  b
0  1  1
1  2  2
2  3  3
mflova commented 2 months ago

I apologize, it seems I was using some outdated versions I should have checked. It is fixed now. I will start using the tool. Thanks!