In [1]:
import numpy as np
import pandas as pd
import utilities as utils
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
data = pd.read_csv("data/food.csv")
In [3]:
print data.shape
data.head()
Out[3]:
In [4]:
usa_data = utils.getByCountry(data, 'United States')
print usa_data.shape
In [5]:
usa_data.describe()
Out[5]:
In [6]:
sugar = usa_data.sugars_100g[usa_data.sugars_100g.notnull()]
most_sugar = sugar.sort_values(ascending=False)
usa_data[usa_data.sugars_100g >= most_sugar.iloc[0]]
Out[6]:
In [7]:
unique_countries = utils.getUniqueCountries(data)
In [8]:
sugar_avg = utils.compareCountriesByNutrimentAverage(data, unique_countries, 'sugars_100g')
p = sugar_avg.plot(kind='bar', legend=False, title='Average Sugars_100g By Country (w/ Sample Size > 30)')
p.set_xlabel("Country")
p.set_ylabel("Grams")
p
Out[8]:
In [14]:
energy_avg = utils.compareCountriesByNutrimentAverage(data, unique_countries, 'energy_100g')
p = energy_avg.plot(kind='bar', legend=False, title='Average Energy_100g By Country (w/ Sample Size > 30)')
p.set_xlabel("Country")
p.set_ylabel("Grams")
p
Out[14]:
In [15]:
sodium_avg = utils.compareCountriesByNutrimentAverage(data, unique_countries, 'sodium_100g')
p = sodium_avg.plot(kind='bar', legend=False, title='Average Sodium_100g By Country (w/ Sample Size > 30)')
p.set_xlabel("Country")
p.set_ylabel("Grams")
p
Out[15]:
In [16]:
fat_100g = utils.compareCountriesByNutrimentAverage(data, unique_countries, 'fat_100g')
p = fat_100g.plot(kind='bar', legend=False, title='Average Fat_100g By Country (w/ Sample Size > 30)')
p.set_xlabel("Country")
p.set_ylabel("Grams")
p
Out[16]:
In [17]:
proteins_100g = utils.compareCountriesByNutrimentAverage(data, unique_countries, 'proteins_100g')
p = proteins_100g.plot(kind='bar', legend=False, title='Average Proteins_100g By Country (w/ Sample Size > 30)')
p.set_xlabel("Country")
p.set_ylabel("Grams")
p
Out[17]:
In [18]:
carbohydrates_100g = utils.compareCountriesByNutrimentAverage(data, unique_countries, 'carbohydrates_100g')
p = carbohydrates_100g.plot(kind='bar', legend=False, title='Average Carbohydrates_100g By Country (w/ Sample Size > 30)')
p.set_xlabel("Country")
p.set_ylabel("Grams")
p
Out[18]:
In [ ]: