# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # TASK 1

# Research Question : The effects of protein and fat intake percentage from animal products on COVID-19 death cases.

# + tags=[]
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# -

# 1. Import Dataset
# The related dataset is imported.

proteinSupply = pd.read_csv('/Users/izgikocacelebi/Downloads/Protein_Supply_Quantity_Data.csv')
proteinSupply

fatSupply = pd.read_csv("/Users/izgikocacelebi/Downloads/Fat_Supply_Quantity_Data.csv")
fatSupply

# + tags=[]
food_descriptions = pd.read_csv("/Users/izgikocacelebi/Downloads/Supply_Food_Data_Descriptions.csv")
# -

food_descriptions

# 2. Data Cleaning

proteinSupply = proteinSupply[['Country','Animal Products','Deaths']]
proteinSupply

fatSupply = fatSupply[['Country','Animal Products','Deaths']]
fatSupply

proteinSupply_cleaned = proteinSupply.rename(columns = {
    'Animal Products' : '% Protein in Animal Products',
    'Deaths':'% COVID-19 Deaths'
} )
proteinSupply_cleaned

fatSupply_cleaned = fatSupply.rename(columns = {
    'Animal Products' : '%Fat in Animal Products',
    'Deaths':'% COVID-19 Deaths'
} )
fatSupply_cleaned

print(proteinSupply_cleaned.count(axis = 'rows') )

print(fatSupply_cleaned.count(axis = 'rows'))

# It can be seen that there are 6 rows with missing values in COVID-19 Deaths column.

# - Dealing with missing values

proteinSupply_cleaned = proteinSupply_cleaned.dropna().reset_index()
fatSupply_cleaned = fatSupply_cleaned.dropna().reset_index()

proteinSupply_cleaned

fatSupply_cleaned

proteinSupply_cleaned = proteinSupply_cleaned.drop(['index'],axis =1)
fatSupply_cleaned = fatSupply_cleaned.drop(['index'],axis=1)

proteinSupply_cleaned

fatSupply_cleaned

#  3. Data Processsing

fat = pd.DataFrame(fatSupply_cleaned['%Fat in Animal Products'])
fat

animalProd = pd.concat([proteinSupply_cleaned,fat], axis = 1)
animalProd

animalProd = animalProd.reindex(columns = ['Country','% Protein in Animal Products', '%Fat in Animal Products', '% COVID-19 Deaths'])

animalProd.dropna()

animalProd.to_csv("izgi_analysis.csv")


# # Task 2

# ## Method Chaining

# +
def load_and_process(fat_path, protein_path) :
    
    df1 = pd.read_csv(fat_path)[['Country','Animal Products','Deaths']].rename(columns = {
    'Animal Products' : '%Fat in Animal Products',
    'Deaths':'% COVID-19 Deaths'
    }).dropna().reset_index().drop(['index', 'Country','% COVID-19 Deaths'],axis =1)
    
    
    df2 = pd.read_csv(protein_path)[['Country','Animal Products','Deaths']].rename(columns = {
    'Animal Products' : '% Protein in Animal Products',
    'Deaths':'% COVID-19 Deaths'
    }).dropna().reset_index().drop(['index'], axis =1)
    
    df3 = pd.concat([df2,df1],axis =1).reindex(columns = ['Country','% Protein in Animal Products', '%Fat in Animal Products', '% COVID-19 Deaths'])
    return df3

load_and_process("/Users/izgikocacelebi/Downloads/Fat_Supply_Quantity_Data.csv",'/Users/izgikocacelebi/Downloads/Protein_Supply_Quantity_Data.csv')

# + tags=[]
from scripts import project_function as pt
df4 = pt.load_and_process("/Users/izgikocacelebi/Downloads/Fat_Supply_Quantity_Data.csv",'/Users/izgikocacelebi/Downloads/Protein_Supply_Quantity_Data.csv')
# -

# # Task 3 :EDA

animalProd.describe(exclude = np.object).T

# + tags=[]
from pandas_profiling import ProfileReport
# -

profile = pandas_profiling.ProfileReport(animalProd)
display(profile)

# +
## Visualizations
# -

p1_protein = sns.scatterplot(data = animalProd, x ='% Protein in Animal Products', y= "% COVID-19 Deaths")
p2_fat = sns.scatterplot(data = animalProd, x ='%Fat in Animal Products', y="% COVID-19 Deaths", marker = 'x')
plt.legend(["% Protein in Animal Products","% Fat in Animal Products"],bbox_to_anchor = (1.4,1))
p1_protein.set(title = "The relationship between Protein and Fat Consumed from Animal Products and COVID-19 Deaths")

# # Conclusion
# It can be concluded that %Protein and Covid-19 Deaths have strong positive linear correlation. Similarly, %Fat and Covid-19 Deaths also have a strong positive linear correlation. However, the information is not enough to conclude whether consuming meat products can lower our chances to survive COVID-19. To reach this conclusion, further analysis is required.



StarcoderdataJupyterScriptsDedupFiltered