While the latest USDA-ERS shows the Indices of total farm output, data from 1948 - 2019 is on a steady climb,
we still have food shortages and climbing food prices.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
fig1, ax1 = plt.subplots(figsize = (5,3))
# Get Indices of total farm output, data from 1948 - 2019
df = pd.read_csv('Indices_of_farm_output.csv')
#print(df[(df['Attribute'] == 'Total agricultural output')])
total_Agri_Out = df[(df['Attribute'] == 'Total agricultural output')]
ax1.plot(total_Agri_Out['Year'], total_Agri_Out['Value'])
plt.xlabel('Yearly change', size=12)
plt.ylabel('Farm output value', size=12)
plt.title('Yearly Farm Output from 1948 - 2019', size=14)
fig1
import pandas as pd
print('While the plot above does show yearly total farm output. It is actually comprised of a number of catagories such as eggs.')
df = pd.read_csv('Indices_of_farm_output.csv')
poultry_eggs = df[(df["Attribute"] == "Livestock and products output: Poultry and eggs")]
poultry_eggs = poultry_eggs.reset_index(drop=True)
#select_start = df.loc[df['Year'] == '1948']
#select_end = df.loc[df['Year'] == '2019']
onerow = poultry_eggs[poultry_eggs['Year'] == '1948']
beg = poultry_eggs.iloc[0]
#print(beg)
end = poultry_eggs.iloc[70]
#print(end)
data = (beg, end )
df_year = pd.DataFrame(data)
df_year = df_year.reset_index(drop=True)
diff_total = df_year['Value'].diff()
#print(diff_total)
print('The difference in the egg output from 1948 and 2019 is 0.96187')
#poultry_eggs = df[(df["Attribute"] == "Livestock and products output: Poultry and eggs")]
avg_value = poultry_eggs.Value.mean(),0
print(f"The average value of egg output from 1948 - 2019 is: {avg_value}")
total_eggs = poultry_eggs['Value'].sum()
print(f"Total years of eggs production is {total_eggs}")
col_count = len(poultry_eggs.axes[1])
print(f"Column count for eggs {col_count}")
row_cnt = poultry_eggs.count()[0]
print(f"Row count for eggs {row_cnt}")
Food shortages & Price increase
Global food prices started to rise in mid-2020 when businesses shut down due to the COVID-19 pandemic,
straining supply chains. Farmers dumped out milk and let fruits and vegetables rot due to a lack of available truckers to transport goods to supermarkets,
where prices spiked as consumers stockpiled food. A shortage of migrant labor as lockdowns restricted movement impacted crops worldwide.
The latest food index from the Bureau of Labor Statistics climbed 10.1 percent for the 12 months ending in May, the first increase of over 10 percent since 1981.
Climate change , the war with Russia's invasion of Ukraine. China, Brazil are also top crop exports have had severe issues.
SNS Plot (Some catagories have multiple plots due to USDA ERS grouping)
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
import seaborn as sns
dfood = pd.read_csv('cpifoodt.csv')
print('\n')
dfood = dfood.drop(columns=['Top-level', 'Aggregate', 'Low-level','Disaggregate', 'Adjustment relative to last month'])
attributeRowDropList = ['Relative importance', 'Month-to-month April 2022 to May 2022','Year-over-year May 2021 to May 2022', 'Year-to-date avg. 2021 to avg. 2022',
'20-year historical average', 'Lower bound of forecast range 2022', 'Upper bound of forecast range 2022']
dfood = dfood[~dfood['Attribute'].isin(attributeRowDropList)]
dfood = dfood.dropna(subset=['Mid-level'])
dfood = dfood.reset_index(drop=True)
print('\n')
fig1, ax1 = plt.subplots(figsize = (20,6))
ax1 = sns.scatterplot(x=dfood['Value'],y=dfood['Mid-level'], hue=dfood['Attribute'])
plt.xlabel('Price percentage changed', size=20)
plt.ylabel('Food catagories', size=20)
plt.title('Price Index on Food 2019 - 2021', size=20)
ax1.grid()
fig1
Combat food price increases!
Find and visit a farmers market in your area.
Farmers Markets - Looking for local/seasonal food from nearby farmers markets?
These markets are great for fresh food and lower prices. You are also supporting a local farmer.
Unfortunately I ran out of time trying to get the online searh for farmers market to work through python on this page.
Please follow the links below to check or try them on Github, they will prompt you for a zip code and make a WSDL request for farmers markets in your area.
Really basic REPL, not fully implemented yet. Just having fun with it
Tip: press Shift-ENTER to evaluate a cell or hover in the cell and a run arrow will show to far right.
Refresh screen to start over.