Skip to content

Commit

Permalink
Added a few testing files
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriguez03 committed Feb 16, 2024
1 parent 47d8799 commit 00e36ad
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import panda as pd



@st.cache_data
def get_UN_data():
AWS_BUCKET_URL = "https://streamlit-demo-data.s3-us-west-2.amazonaws.com"
df = pd.read_csv(AWS_BUCKET_URL + "/agri.csv.gz")
return df.set_index("Region")

try:
df = get_UN_data()
countries = st.multiselect(
"Choose countries", list(df.index), ["China", "United States of America"]
)
if not countries:
st.error("Please select at least one country.")
else:
data = df.loc[countries]
data /= 1000000.0
st.write("### Gross Agricultural Production ($B)", data.sort_index())

data = data.T.reset_index()
data = pd.melt(data, id_vars=["index"]).rename(
columns={"index": "year", "value": "Gross Agricultural Product ($B)"}
)
chart = (
alt.Chart(data)
.mark_area(opacity=0.3)
.encode(
x="year:T",
y=alt.Y("Gross Agricultural Product ($B):Q", stack=None),
color="Region:N",
)
)
st.altair_chart(chart, use_container_width=True)
except URLError as e:
st.error(
"""
**This demo requires internet access.**
Connection error: %s
"""
% e.reason
)

0 comments on commit 00e36ad

Please sign in to comment.