initial commit /n/n co2plot.py makes the plots. runnint Processing chunk 1 named None from line 3

Processing chunk 2 named None from line 10
Processing chunk 3 named None from line 17
Processing chunk 4 named None from line 28
Published co2plot.py to co2plot.html will create the report
This commit is contained in:
Waylon Walker 2017-04-01 13:50:46 -05:00
parent 9fe8510454
commit 2e731f31de

32
co2plot.py Normal file
View file

@ -0,0 +1,32 @@
#' #Testing out pweave on android with Termux
import matplotlib
matplotlib.use('agg')
from tabulate import tabulate
from co2data import df
#' ## raw data
#' *from data.world*
# This example will plot the co2 emissions trend for the top 5 countries in 2011
print(tabulate(df.iloc[0:10, 0:5], headers=df.columns, tablefmt='simple'))
#' ## Transform Data for plotting
#'
plot_df = (df
.set_index('CO2 emission total')
.sort_values('2011', ascending=False)
.head(5)
.T
.dropna(how='all')
)
print(tabulate(plot_df.iloc[0:10, 0:5], headers=plot_df.columns, tablefmt='simple'))
#' Plot the data
title = 'Top 5 countries CO2 emissions trend\n(based on 2011 emissions data)'
ax = plot_df.plot(title=title)
ax.figure.savefig('tmp.png')