hgrecco / pint-pandas

Pandas support for pint
Other
166 stars 41 forks source link

pint.dequantify() fails for duplicate column names #202

Closed mmarras closed 8 months ago

mmarras commented 10 months ago

df.pint.dequantify() breaks unexpectedly (and error msg is cryptic) if column names contain duplicates.

df = pd.DataFrame()
df['test']= pd.Series([1,2,3], dtype='pint[kN]')
df.insert(0,'test',df['test'],allow_duplicates=True)

df:

  test test
0 1 1
1 2 2
2 3 3

df.iloc[:,1:].pint.dequantify()
--| test --|-- unit| kN 0|1 1|2 2|3
df.pint.dequantify()

'DataFrame' object has no attribute 'dtype'

pint_pandas.version = 0.4, python 3.10