Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with this python code! import streamlit as st import pandas as pd import matplotlib.pyplot as plt @st.cache def load_data(): df = pd.read_csv('daily_electricity.csv', index_col='Date')

Please help with this python code!

import streamlit as st import pandas as pd import matplotlib.pyplot as plt

@st.cache def load_data(): df = pd.read_csv('daily_electricity.csv', index_col='Date') return df

st.title('Electricity Production by Source')

# load the data df = load_data()

# show the data in a table if st.sidebar.checkbox('Show dataframe'): st.write(df)

# choose the sources of interest cols = ['Coal_MW', 'Gas_MW', 'Hidroelectric_MW', 'Nuclear_MW', 'Wind_MW', 'Solar_MW', 'Biomass_MW'] option = st.multiselect('What sources do you want to display?', cols, cols[0])

# plot the data if st.sidebar.checkbox('Show Streamlit line_chart'): st.line_chart( df[option] ) else: fig, ax = plt.subplots() df[option].plot(ax=ax) st.write( fig )

# # TODO - when a checkbox in sidebar checked: # # (1) print the mean daily production for the sources selected # # (2) show a bar chart using the mean daily production for the sources selected

.csv:

Date,Consumption_MW,Coal_MW,Gas_MW,Hidroelectric_MW,Nuclear_MW,Wind_MW,Solar_MW,Biomass_MW,Production_MW 2010-01-03,874810.0,347240.0,153451.0,284290.0,87668.0,0.0,0.0,0.0,872639.0 2010-01-04,933653.0,262921.0,93664.0,372362.0,203503.0,0.0,0.0,0.0,932485.0 2010-01-05,765805.0,240812.0,34818.0,275409.0,205383.0,0.0,0.0,0.0,756438.0 2010-01-06,879815.0,366273.0,25326.0,405128.0,99650.0,0.0,0.0,0.0,896343.0 2010-01-07,883756.0,330657.0,40238.0,385101.0,200889.0,3813.0,0.0,0.0,960675.0 2010-01-08,734463.0,190320.0,40641.0,353715.0,193858.0,839.0,0.0,0.0,779418.0 2010-01-09,821876.0,373102.0,45703.0,304001.0,190029.0,15822.0,0.0,0.0,928628.0 2010-01-10,715882.0,294525.0,59053.0,245091.0,162815.0,1710.0,0.0,0.0,763154.0 2010-01-11,938442.0,402670.0,153290.0,274980.0,192068.0,10324.0,0.0,0.0,1033294.0 2010-01-12,1007868.0,384456.0,179390.0,329413.0,198211.0,12968.0,0.0,0.0,1104379.0 2010-01-13,1042004.0,373011.0,194863.0,306284.0,201059.0,0.0,0.0,0.0,1075218.0 2010-01-14,1042509.0,369633.0,197262.0,346310.0,168176.0,0.0,0.0,0.0,1081372.0 2010-01-15,1055215.0,388660.0,203033.0,347183.0,164323.0,0.0,0.0,0.0,1103199.0 2010-01-16,996037.0,434489.0,190963.0,286464.0,99345.0,0.0,0.0,0.0,1011250.0 2010-01-17,919143.0,391417.0,183487.0,241442.0,98423.0,0.0,0.0,0.0,914765.0 2010-01-18,1068603.0,412041.0,194938.0,296893.0,174299.0,0.0,0.0,0.0,1078158.0 2010-01-19,1080671.0,412926.0,201113.0,301244.0,201631.0,0.0,0.0,0.0,1116914.0 2010-01-20,1084070.0,401084.0,199003.0,308907.0,202249.0,0.0,0.0,0.0,1111238.0 2010-01-21,1100944.0,414256.0,195273.0,314447.0,204295.0,0.0,0.0,0.0,1128266.0 2010-01-22,1118881.0,421246.0,196517.0,320930.0,203939.0,0.0,0.0,0.0,1142629.0 2010-01-23,1024722.0,394959.0,185847.0,252177.0,200800.0,0.0,0.0,0.0,1033773.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

1. What do I mean? Do I define things adequately?

Answered: 1 week ago