Skip to content

Instantly share code, notes, and snippets.

@naenumtou
Created July 27, 2020 06:37
Show Gist options
  • Save naenumtou/f2f6861d29e79eafb497351ab8f86a07 to your computer and use it in GitHub Desktop.
Save naenumtou/f2f6861d29e79eafb497351ab8f86a07 to your computer and use it in GitHub Desktop.
#Convert values
df['date'] = pd.to_datetime(df['date'])
df['total'] = pd.to_numeric(df['total'])
#Summary table
df = pd.pivot_table(df, index = ['country','date'], columns = ['types'], aggfunc = np.sum)
df.columns = df.columns.droplevel(0)
df = df.reset_index()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment