Skip to content

RTFM and could not make pint[Mt CO2] work as a unit #32

@MichaelTiemannOSC

Description

@MichaelTiemannOSC

I've spent a good hour probing docs(and sample notebooks) between openscm-units, openscm, pint, and pint-pandas. What I have not figured out how to do is make this work:

import pandas as pd
import pint_pandas
from openscm_units import unit_registry
one_co2 = unit_registry("CO2")
print(one_co2)

x = pd.DataFrame([[1.0,'Mt CO2']], columns=['Value', 'Unit'])
x.astype({'Value': 'pint[Mt CO2]'}).dtypes

My one_co2 is 1 CO2, but pint complains: UndefinedUnitError: 'CO2' is not defined in the unit registry

What am I missing? What changes could I help put into the docs for others to use openscm-units successfully?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions