Finance

Finance-specific data cleaning functions.

janitor.finance.convert_currency(df: pandas.core.frame.DataFrame, api_key: str, column_name: str = None, from_currency: str = None, to_currency: str = None, historical_date: datetime.date = None, make_new_column: bool = False) → pandas.core.frame.DataFrame[source]

Deprecated function.

janitor.finance.inflate_currency(df: pandas.core.frame.DataFrame, column_name: str = None, country: str = None, currency_year: int = None, to_year: int = None, make_new_column: bool = False) → pandas.core.frame.DataFrame[source]

Inflates a column of monetary values from one year to another, based on the currency’s country.

The provided country can be any economy name or code from the World Bank list of economies: https://databank.worldbank.org/data/download/site-content/CLASS.xls.

This method mutates the original DataFrame.

Functional usage example:

import pandas as pd
import janitor.finance

df = pd.DataFrame(...)

df = janitor.finance.inflate_currency(
    df=df,
    column_name='profit',
    country='USA',
    currency_year=2015,
    to_year=2018,
    make_new_column=True
)

Method chaining usage example:

import pandas as pd
import janitor.finance

df = pd.DataFrame(...)
df = df.inflate_currency(
    column_name='profit',
    country='USA',
    currency_year=2015,
    to_year=2018,
    make_new_column=True
)
Parameters
  • df – A pandas dataframe.

  • column_name – Name of the column containing monetary values to inflate.

  • country – The country associated with the currency being inflated. May be any economy or code from the World Bank list of economies: https://databank.worldbank.org/data/download/site-content/CLASS.xls.

  • currency_year – The currency year to inflate from. The year should be 1960 or later.

  • to_year – The currency year to inflate to. The year should be 1960 or later.

  • make_new_column – Generates new column for inflated currency if True, otherwise, inflates currency in place.

Returns

The dataframe with inflated currency column.