hgrecco / pint-pandas

Pandas support for pint
Other
166 stars 40 forks source link

`.to()` method not available within the pint dataframe accessor #232

Open mflova opened 1 month ago

mflova commented 1 month ago

I was playing with some of the examples within the docs. Here I found there is supposed to be pint.to() to convert to specific units. I tried to followed the example in this page but .to seems not to be an attribute of the Pint dataframe accessor.

I printed the attributes of the accessor and I got: convert_object_dtype, dequantify, quantify, to_base_units. I saw from the source code that some other attributes such as to are delegated to the Series, but not to the dataframe. If there are future intentions of adding it to the whole dataframe, I will be happy to add it

andrewgsavage commented 1 month ago

It's a series accessor. You could make a pr adding a data frame accessor. You'd need to handle columns with non pint type, such as int or float or string, and pint types that have different dimensionality so shouldn't be converted.