Skip to content

Instantly share code, notes, and snippets.

@joaomacalos
Created June 15, 2021 13:43
Show Gist options
  • Select an option

  • Save joaomacalos/a28e87a1c2f0cc7d47309a8fe6ea0e50 to your computer and use it in GitHub Desktop.

Select an option

Save joaomacalos/a28e87a1c2f0cc7d47309a8fe6ea0e50 to your computer and use it in GitHub Desktop.
Comparison-Python1
# Load required libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Read csv
commodities = pd.read_csv('../../../Datasets/imf-commodities.csv')
# Data wrangling
commodities = (
commodities
.loc[3:, ['Commodity', 'PALLFNF']]
.dropna()
.assign(
date=lambda x: pd.to_datetime(x.Commodity, format='%YM%m'),
comm=lambda x: x.PALLFNF.astype('float')
)
)
commodities.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment