<jupyter_start><jupyter_text>![alt text](https://github.com/callysto/callysto-sample-notebooks/blob/master/notebooks/images/Callysto_Notebook-Banner_Top_06.06.18.jpg?raw=true)  Case Study: Greenhouse gas emissions, by province and territory (1990, 2005, 2017)Greenhouse gas emissions – Greenhouse gas emissions by province and territory, CanadaGeography: Canada, Provinces and Territories ofSourceOpen Government Datahttps://open.canada.ca/data/en/dataset/9a673fa1-22af-41c1-9ae5-de38de714c83<jupyter_code># # Download data 
# DATA SET PRODUCT ID  for internal use only. 
import pandas as pd
link = "https://www.canada.ca/content/dam/eccc/documents/csv/cesindicators/ghg-emissions/2019/GHG-emissions-province-en.csv"
df_less2 = pd.read_csv(link)
df_less2 = df_less2.dropna(how='all')
prov_df = df_less2.iloc[:-3]
new_header = prov_df.iloc[0]
data_df = prov_df.iloc[1:]
data_df.columns = new_header
data_df = data_df.fillna(0)
data_df = data_df.replace({'1.6[A]': "1.6"})
data_df.iloc[:,1:]= data_df.iloc[:,1:].astype(float)
data_df = data_df.set_index("Province or territory")
data_df
#load "cufflinks" library under short name "cf"
import cufflinks as cf

#command to display graphics correctly in Jupyter notebook
cf.go_offline()

def enable_plotly_in_cell():
    import IPython
    from plotly.offline import init_notebook_mode
    display(IPython.core.display.HTML('''<script src="/static/components/requirejs/require.js"></script>'''))
    init_notebook_mode(connected=False)
    
get_ipython().events.register('pre_run_cell', enable_plotly_in_cell)

# Bar plot for provinces 
layout = dict(yaxis=dict(side='left'),\
              title='Greenhouse gas emissions by province and territory, Canada, 1990, 2005 and 2017')
my_fig = data_df.iplot(layout= layout,asFigure=True,kind='bar')
my_fig.layout.legend=dict(x=-0.01, y=1.0)
my_fig.iplot(filename='line-example.html') 
layout = dict(yaxis=dict(side='left'),\
              title='Greenhouse gas emissions by province and territory, Canada, 1990, 2005 and 2017')
my_fig2 = data_df.iplot(layout= layout,asFigure=True,kind='box')
my_fig2.update_layout(showlegend=False)
my_fig2.iplot(filename='line-example.html') 
link2 = "https://www.canada.ca/content/dam/eccc/documents/csv/cesindicators/ghg-emissions/2019/GHG-emissions-sector-en.csv"
greenhouse_sector = pd.read_csv(link2)
greenhouse_sector = greenhouse_sector.dropna()
new_head = greenhouse_sector.iloc[0]
greenhouse_sector = greenhouse_sector.iloc[1:]
greenhouse_sector.columns = new_head
greenhouse_sector = greenhouse_sector.set_index("Year")
greenhouse_sector
greenhouse_sector = greenhouse_sector.astype(float)
layout = dict(yaxis=dict(side='left'),\
              title='Greenhouse gas emissions by sector, Canada, 1990-2017')
my_fig3 = greenhouse_sector.iplot(layout= layout,asFigure=True,kind='box')
my_fig3.update_layout(showlegend=False)
my_fig3.iplot(filename='line-example.html') 

layout = dict(yaxis=dict(side='left'),\
              title='Greenhouse gas emissions by sector, Canada, 1990-2017')
my_fig4 = greenhouse_sector.iplot(layout= layout,asFigure=True,kind='line')
my_fig4.update_layout(showlegend=True)
my_fig4.iplot(filename='line-example.html')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13154613466334164, 'fraction_numerical': 0.036471321695760596, 'mean_word_length': 6.276643990929705, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '240403', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1119, 'n_words': 193, 'path': 'Case_Studies_Notebooks/greenhouse-gas-emissions-by-province-and-territory.ipynb', 'repo_name': 'callysto/SustainabilityCaseStudies', 'size': '3208'}