text_plain_output_1.png
from pprint import pprint

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pprint

df = pd.read_csv('/kaggle/input/starbucks-nutrition/starbucks.csv', index_col=0)

df.describe

df.isnull().sum()

highest_calorie_item = df.loc[df['calories'].idxmax(), 'item']
highest_calorie_value = df['calories'].max()
lowest_calorie_item = df.loc[df['calories'].idxmin(), 'item']
lowest_calorie_value = df['calories'].min()

highest_fat_item = df.loc[df['fat'].idxmax(), 'item']
highest_fat_value = df['fat'].max()
highest_carb_item = df.loc[df['carb'].idxmax(), 'item']
highest_carb_value = df['carb'].max()
highest_fiber_item = df.loc[df['fiber'].idxmax(), 'item']
highest_fiber_value = df['fiber'].max()
highest_protein_item = df.loc[df['protein'].idxmax(), 'item']
highest_protein_value = df['protein'].max()

average_calories = df.groupby('type')['calories'].mean()

correlation = df[['calories', 'fat', 'carb', 'fiber', 'protein']].corr()
for nutrient in ['fat', 'carb', 'fiber', 'protein']:
    corr_value = correlation.loc['calories', nutrient]

average_nutrients = df.groupby('type')[['fat', 'carb', 'fiber', 'protein']].mean()
for nutrient in ['fat', 'carb', 'fiber', 'protein']:
    max_nutrient_type = average_nutrients[nutrient].idxmax()
    max_nutrient_value = average_nutrients[nutrient].max()

mean_nutrients = df.groupby('type')[['fat', 'carb', 'fiber', 'protein']].mean()
nutrient_columns = mean_nutrients.columns
for nutrient in nutrient_columns:
    nutrient_values = mean_nutrients[nutrient]
    plt.xticks(rotation=45)

# Calculate summary statistics for each nutrient by food item type
summary_statistics = df.groupby('type')[['fat', 'carb', 'fiber', 'protein']].describe()

# Use pprint for pretty printing
pp = pprint.PrettyPrinter()

# Print the summary statistics
print("Summary Statistics for Nutrient Values by Food Item Type:")
pp.pprint(summary_statistics)

mean_fat_by_type = df.groupby('type')['fat'].mean()
pp = pprint.PrettyPrinter()
print('Mean Fat Content by Food Item Type:')
pp.pprint(mean_fat_by_type)