Pandas tools

Created on Tue Dec 22 09:34:50 2020

@author: ageiges

datatoolbox.tools.pandas.add_standard(table, iso_type='alpha3')[source]

Convert index of a dataframe into iso codes.

Parameters

tablepandas.Dataframe or dt.DataTable

Index of thos table consists of country strings.

isoTYPE, optional

Either ‘alpha3’, alpha2 or numISO. The default is ‘alpha3’.

Returns

tablepandas.Dataframe or dt.DataTable

Return old dataframe with new iso index.

datatoolbox.tools.pandas.isin(df=None, **filters)[source]

Constructs a MultiIndex selector

Usage

> df.loc[isin(region=”World”, gas=[“CO2”, “N2O”])] or with explicit df to get a boolean mask > isin(df, region=”World”, gas=[“CO2”, “N2O”])

datatoolbox.tools.pandas.yearsColumnsOnly(index)[source]

Extracts from any given index only the index list that can resemble as year

e.g. 2001