hgrecco / pint-pandas

Pandas support for pint
Other
166 stars 41 forks source link

Support .to() to convert a pint-pandas PintArray #224

Closed samvanstroud closed 2 months ago

samvanstroud commented 2 months ago

The standard PintArray supports casting with .to() as mentioned in the pint docs.

With a pint_pandas.pint_array.PintArray I get a AttributeError: 'PintArray' object has no attribute 'to'.

andrewgsavage commented 2 months ago

Those are the docs for pint's numpy support not for pandas

PintArray does not have a .to() method. If you make it into a Series you can use Series.pint.to() https://pint-pandas.readthedocs.io/en/latest/getting/tutorial.html#pandas-series-accessors

There's also PintArray.quantity.to(). Neither will return a PintArray though.

How are you using PintArrays? They aren't really intended for outside of Series or DataFrame as they don't have many of the properties/methods that Quantity has.

samvanstroud commented 2 months ago

thanks @andrewgsavage! I think I just missed this in the docs, apologies