Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
TBrost committed Oct 13, 2023
1 parent 3f5745a commit 81dd90e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
Binary file modified __pycache__/basis_prices.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/cash_prices.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/futures_prices.cpython-311.pyc
Binary file not shown.
31 changes: 24 additions & 7 deletions cash_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def cash_page():


#st.download_button("Download Data", df)
on = st.toggle('Filter by City')

CITY = st.selectbox(
'Select a City',
'Select a City (only works if switch above is active)',
('Rexburg / Ririe','Idaho Falls','Blackfoot / Pocatello','Grace / Soda Springs','Burley / Rupert','Meridian',
'Nezperce / Craigmont','Lewiston','Twin Falls / Buhl / Jerome / Wendell','Moscow / Genesee'))


ATTRIBUTE = st.selectbox(
'Select a Strain',
('Barley (Feed)', 'Barley (Malting)', 'SWW (Milling)', 'HRW (11.5% Protein)', 'DNS (14% Protein)', 'HWW'))
Expand All @@ -45,20 +48,34 @@ def cash_page():
# Filter the DataFrame based on the selected date range
df = df[(df['Date'] >= start_date) & (df['Date'] <= end_date)]

df = df[['Location','year','week_of_year', 'Attribute','Value']]
wheat_table=df.query('Attribute == @ATTRIBUTE & Location == @CITY')
wheat_table = df[['year','week_of_year', 'Attribute','Value']]
wheat_table=wheat_table.query('Attribute == @ATTRIBUTE')
wheat_table = wheat_table.groupby(['year', 'week_of_year', 'Attribute'])['Value'].mean().reset_index()

df_pivot = wheat_table.pivot(index=['Attribute','week_of_year', 'Location'], columns=['year'], values='Value')
df_pivot['Average'] = df_pivot.mean(axis=1)
df_pivot = wheat_table.pivot(index=['Attribute','week_of_year'], columns=['year'], values='Value')
df_pivot['Average'] = df_pivot.mean(axis=1).round(2)
df_pivot['Median'] = df_pivot.median(axis=1)
df_pivot['Max'] = df_pivot.max(axis=1)
df_pivot['Min'] = df_pivot.min(axis=1)
df_pivot['Standard Deviation'] = df_pivot.std(axis=1)
df_pivot = df_pivot.reset_index(names=['Attribute', 'week of year'])

df_pivot = df_pivot.reset_index(names=['Attribute', 'week of year', 'Location'])
st.dataframe(df_pivot)
if on:
wheat_table = df[['Location','year','week_of_year', 'Attribute','Value']]
wheat_table=wheat_table.query('Attribute == @ATTRIBUTE & Location == @CITY')

df_pivot = wheat_table.pivot(index=['Attribute','week_of_year', 'Location'], columns=['year'], values='Value')
df_pivot['Average'] = df_pivot.mean(axis=1)
df_pivot['Median'] = df_pivot.median(axis=1)
df_pivot['Max'] = df_pivot.max(axis=1)
df_pivot['Min'] = df_pivot.min(axis=1)
df_pivot['Standard Deviation'] = df_pivot.std(axis=1)

df_pivot = df_pivot.reset_index(names=['Attribute', 'week of year', 'Location'])
st.dataframe(df_pivot)

if not on:
CITY = "Idaho"

filename= f'{ATTRIBUTE}_{CITY}_data.csv'
def convert_df(df):
Expand Down

0 comments on commit 81dd90e

Please sign in to comment.