<jupyter_start><jupyter_text>FAO Data on Food Production in SurinameData from FAO Stat (https://www.fao.org/faostat/en/data/QCL)<jupyter_code>import pandas as pd
import os
import matplotlib.pyplot as plt
import numpy as np
os.getcwd()
os.chdir(r"C:\Users\valer\OneDrive\Dokumente\CVs _ Applications\Correlaid 2021")
food = pd.read_csv("FAOSTAT_data_11-11-2021.csv")
food.info()
food.head(5)
food.nunique()
#remove domain code, domain, area code and area which are always the same
food = food.loc[:,"Element Code": "Flag Description"]
food["Item"].value_counts()
food["Element"].value_counts()
#Find out which items produced most in 2019 (last year)
#include only if "Element" == "Production"

production = food[food["Element"] == "Production"]
production_2019 = production.loc[production["Year"] == 2019]
production_2019.sort_values(by="Value", ascending = False).head(10) #Method for sorting data frames<jupyter_output><empty_output><jupyter_text>Most common crops in 2019: rice, followed by sugar cane, (eggs), bananas, oranges<jupyter_code>#Create separate datasets for production of most common items

def new_set(item):
    return production.loc[production["Item"] == item]

rice_production = new_set("Rice, paddy")
sugar_cane_production = new_set("Sugar cane")
banana_production = new_set("Bananas")
orange_production = new_set("Oranges")
plt.plot(rice_production["Year"], rice_production["Value"])
plt.xticks([2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019])
plt.show()
#Creating subplots for different crops

figure, axis = plt.subplots(2, 2, sharey = True) #Creates template for subplots; sharey means that the y-axis is shared for all plots (not scaled individually)

plt.setp(axis, xticks=[2011, 2013, 2015, 2017, 2019]) #to set certain things for all subplots
plt.suptitle("Food production for most common crops per year", fontweight = "bold")
plt.setp(axis, ylabel = "Production per year \nin tonnes")

axis[0,0].plot(rice_production["Year"], rice_production["Value"])
axis[0,0].set_title("Rice production")

axis[0,1].plot(sugar_cane_production["Year"], sugar_cane_production["Value"])
axis[0,1].set_title("Sugar cane production")

axis[1,0].plot(banana_production["Year"], banana_production["Value"])
axis[1,0].set_title("Banana production")

axis[1,1].plot(orange_production["Year"], orange_production["Value"])
axis[1,1].set_title("Orange production")

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axis.flat:
    ax.label_outer()


#Looking at yield instead


yield1 = food[food["Element"] == "Yield"]
yield1.head(10)
def new_set_yield(item):
    return yield1.loc[yield1["Item"] == item]

rice_yield = new_set_yield("Rice, paddy")
sugar_cane_yield = new_set_yield("Sugar cane")
banana_yield = new_set_yield("Bananas")
orange_yield = new_set_yield("Oranges")
#Creating subplots for different crops

figure, axis = plt.subplots(2, 2, sharey = True) #Creates template for subplots; sharey means that the y-axis is shared for all plots (not scaled individually)

plt.setp(axis, xticks=[2011, 2013, 2015, 2017, 2019]) #to set certain things for all subplots
plt.suptitle("Yield for most common crops per year", fontweight = "bold")
plt.setp(axis, ylabel = "Yield in hg/ha")

axis[0,0].plot(rice_yield["Year"], rice_yield["Value"])
axis[0,0].set_title("Rice yield")

axis[0,1].plot(sugar_cane_yield["Year"], sugar_cane_yield["Value"])
axis[0,1].set_title("Sugar cane yield")

axis[1,0].plot(banana_yield["Year"], banana_yield["Value"])
axis[1,0].set_title("Banana yield")

axis[1,1].plot(orange_yield["Year"], orange_yield["Value"])
axis[1,1].set_title("Orange yield")

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axis.flat:
    ax.label_outer()
#Creating subplots using seaborn.relplot

import seaborn as sns
food_sel = food[(food["Item"] == "Rice, paddy") | (food["Item"] == "Sugar cane") | (food["Item"] == "Bananas") | (food["Item"] == "Oranges")]
food_sel
harvest_plot = sns.relplot(data = food_sel[food_sel["Element"] == "Area harvested"], x = "Year", y = "Value", 
            kind = "line", hue = "Item")

harvest_plot.set(xlabel='Year', ylabel='Area harvested in ha')
harvest_plot.set(title = "Area harvested for different crops")
food["Item"].value_counts()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14853556485355648, 'fraction_numerical': 0.036494653649465365, 'mean_word_length': 6.683928571428571, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '655625', 'license': 'MIT', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1440, 'n_words': 385, 'path': 'notebooks/Crop production.ipynb', 'repo_name': 'CorrelAidxNL/slc-hunger-risk', 'size': '4302'}