Created
May 6, 2023 01:46
-
-
Save redavis22/e693beef1a0776c151d026b221f699bd to your computer and use it in GitHub Desktop.
streamlit hurricane shopping items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import streamlit as st | |
from faker import Faker | |
import random | |
# Set up the Faker object | |
fake = Faker() | |
# Create a list of hurricane names | |
hurricane_names = [fake.city() + ' Hurricane' for _ in range(3)] | |
# Create a list of items with emojis | |
items = ['๐ง Bottled Water', '๐ฅซ Canned Food', '๐ฆ Flashlights', '๐ Batteries', '๐ฉน First Aid Kit', | |
'๐ช Utility Knife', '๐ป Portable Radio', '๐ ๏ธ Tool Kit', '๐งญ Compass', '๐งฏ Fire Extinguisher', | |
'๐ Clothing', '๐๏ธ Sleeping Bag', '๐ฐ Water Purifier', '๐งผ Soap', '๐ฝ Toilet Paper', | |
'๐งน Broom', '๐ช Door Lock', '๐ Keys', '๐จ Hammer', '๐ฉ Nails', | |
'๐งฐ Power Drill', '๐งน Dustpan', '๐ง Road Cones', '๐ซ Danger Tape', '๐ First Aid Kit', | |
'๐งฏ Fire Blanket', '๐บ๏ธ Maps', '๐ฎ Flashlight', '๐ฑ Solar Charger', '๐ Batteries', | |
'๐ Generator', '๐ Binoculars', '๐ฌ๏ธ Fan', '๐ Backpack', '๐งน Sweeper', | |
'๐งบ Laundry Bag', '๐ฅพ Hiking Boots', '๐ T-Shirts', '๐ Jeans', '๐ Sneakers', | |
'๐งข Hat', '๐ถ๏ธ Sunglasses', '๐งค Gloves', '๐งฃ Scarf', '๐ฉ<200d>๐ฆฑ Hair Brush'] | |
# Create an empty dictionary to store the data | |
data = {'Item': items} | |
# Loop through the hurricane names and add a random number of items for each hurricane | |
for hurricane in hurricane_names: | |
num_items = [random.randint(10, 100) for _ in range(len(items))] | |
data[hurricane] = num_items | |
# Create a DataFrame from the data dictionary | |
df = pd.DataFrame(data) | |
df.set_index('Item', inplace=True) | |
# Create a Streamlit chart | |
st.line_chart(df) | |
# Create a Streamlit chart | |
st.bar_chart(df) | |
# Create a DataFrame from the data dictionary | |
df = pd.DataFrame(data) | |
df.set_index('Item', inplace=True) | |
# Calculate the cumulative sum of the item counts for each hurricane | |
cumulative_data = df.cumsum() | |
# Create an area chart of the cumulative data | |
st.area_chart(cumulative_data) | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment