%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('dark_background')
df = pd.read_csv('data/recycling-rate-by-waste-type.csv')
df.shape # This will display the number of rows and columns
df.columns # Displays the names of the columns
df.dtypes # Displays the name and type of the columns
df.head() # Displays the first five rows
df.tail() # Displays the last five rows
df.isnull().sum() # Displays columns with blank values
df.columns = ['year', 'wastetype', 'recyclingrate']
df.head()
df.info()
df["year"].unique()
uniquewastetypes = df["wastetype"].unique() # This is placed in a variable
uniquewastetypes
len(uniquewastetypes) # Displays the total number of unique wastetypes in the dataset
totalwastetypes = len(uniquewastetypes)
totalwastetypes
year2015 = df['year'] == 2015
df[year2015]
df['recyclingrate'] = df['recyclingrate'].astype(int) # Ensures that the recyclingrate column is an integer
chart1 = df[year2015].plot.barh(y='recyclingrate', x="wastetype", color='pink', figsize=(8,5))
chart1.set_title("Recycling Rates in 2015", fontsize=20)
chart1.set_xlabel("Recycling Rate in %", fontsize=13)
chart1.set_ylabel("Type of Wastes", fontsize=13)
year2000 = df['year'] == 2000
df[year2000]
chart2 = df[year2000].plot.barh(y='recyclingrate', x="wastetype", figsize=(8,4))
chart2.set_title("Recycling Rates in 2000", fontsize=20)
chart2.set_xlabel("Recycling Rate in %", fontsize=13)
chart2.set_ylabel("Type of Wastes", fontsize=13)
foodwaste = df['wastetype'] == "Food"
df[foodwaste]
# df4 = df.pivot[]
# df.pivot(columns='var', values='val')
chart3 = df[foodwaste].plot(x='year', y='recyclingrate', color='lime', figsize=(10,7))
chart3.set_title("Recycling from 2000 to 2015", fontsize=20)
chart3.set_xlabel("Year", fontsize=13)
chart3.set_ylabel("Recycling Rate in %", fontsize=13)