hgrecco / pint-pandas

Pandas support for pint
Other
169 stars 42 forks source link

how to save units when writing to csv? #98

Closed matthiasdebernardini closed 2 years ago

matthiasdebernardini commented 2 years ago

I want to store a df with pint arrays, how do I store the pint type in csv?

Otherwise I have to readd it when I read it in.

andrewgsavage commented 2 years ago

https://pint.readthedocs.io/en/stable/pint-pandas.html#Reading-from-csv

'df_.pint.to_base_units().pint.dequantify()' gets you to a DataFrame you can write to a csv, then read back in