Skip to content

UnitStrippedWarning with pandas Series #1265

@schlegelp

Description

@schlegelp

Hi!

First things first: big fan of your library! Second: Apologies if that behaviour is expected and/or there is something about it in the docs that I didn't see.

I ran into some unexpected warning when adding a pint.Quantity to a pandas.Series. See this minimal example:

>>> import pint
>>> import pandas as pd
>>> pd.Series([pint.Quantity('8 nm')])                                                                                                                                      
/versions/3.7.5/lib/python3.7/site-packages/pandas/core/dtypes/cast.py:1638: UnitStrippedWarning:

The unit of the quantity is stripped when downcasting to ndarray.

0    8 nanometer
dtype: object

I have yet to confirm but I'm 99% certain that this started after I updated numpy from 1.19.x to 1.20.1. Otherwise running pint==0.16.1 and pandas==1.2.3.

I'm happy to just ignore the warning but I was wondering if there is a "correct" way of doing this.

Cheers,
Philipp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions