Upload folder using huggingface_hub
Browse files- .gitignore +1 -0
- README.md +149 -12
- app.py +4 -0
- pages/1_introduction.py +15 -0
- pages/2_DataFrame_Editor.py +16 -0
- pages/3_Crypto_Tracker.py +21 -0
- pages/4_ToDo_List.py +46 -0
- pages/5_Voting_System.py +34 -0
- pages/6_Weather_Visualization.py +21 -0
- pages/7_Stanford_Policing.py +167 -0
- pages/8_Project_Generator.py +38 -0
- project_ideas.json +41 -0
- requirements.txt +5 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
venv/
|
README.md
CHANGED
|
@@ -1,12 +1,149 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
--
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ๐ฆ **Mega Streamlit App** ๐
|
| 2 |
+
|
| 3 |
+
Welcome to the **Mega Streamlit App**โa powerhouse of interactive features, real-time data, and all-around awesomeness! Whether you want to track cryptocurrency prices, edit DataFrames on the fly, or see how many people are voting for "Option D" (spoiler: no one ever does), this app has you covered.
|
| 4 |
+
|
| 5 |
+
## ๐ **Table of Contents**
|
| 6 |
+
- [Introduction](#introduction)
|
| 7 |
+
- [Features](#features)
|
| 8 |
+
- [Installation](#installation)
|
| 9 |
+
- [Usage](#usage)
|
| 10 |
+
- [Pages Overview](#pages-overview)
|
| 11 |
+
- [Folder Structure](#folder-structure)
|
| 12 |
+
- [Contributing](#contributing)
|
| 13 |
+
- [License](#license)
|
| 14 |
+
- [Contact](#contact)
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## ๐ **Introduction**
|
| 19 |
+
|
| 20 |
+
The **Mega Streamlit App** is a multi-page Streamlit application that demonstrates the endless possibilities of this framework. With everything from a to-do list manager to real-time cryptocurrency tracking, you'll never be bored!
|
| 21 |
+
|
| 22 |
+
Explore a rich dataset like the Stanford Policing Dataset or just marvel at the sheer brilliance of tracking weather in two fictional cities. Whatever your heart desires, we have it!
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## ๐ฅ **Features**
|
| 27 |
+
- **DataFrame Editor**: Edit tables in real-time like a data wizard.
|
| 28 |
+
- **Cryptocurrency Price Tracker**: Keep tabs on Bitcoin, Ethereum, and some random altcoins!
|
| 29 |
+
- **To-Do List Manager**: Because we all need to pretend weโre productive.
|
| 30 |
+
- **Voting System**: Make democracy fun again with real-time voting and live results.
|
| 31 |
+
- **Weather Visualization**: Want to compare the weather in two totally made-up cities? Now you can!
|
| 32 |
+
- **Stanford Policing Dashboard**: Dive deep into data analysis with interactive charts and filters. Warning: serious data ahead!
|
| 33 |
+
- **Random Coding Project Generator**: Feeling uninspired? Let the app throw a project at youโranging from "easy as pie" to "prepare for all-nighters!"
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## ๐ป **Installation**
|
| 38 |
+
|
| 39 |
+
Want to run this bad boy on your own machine? Follow these steps:
|
| 40 |
+
|
| 41 |
+
1. **Clone the repository**:
|
| 42 |
+
```bash
|
| 43 |
+
git clone https://github.com/CNielsen94/my_streamlit_app.git
|
| 44 |
+
```
|
| 45 |
+
2. Navigate to the project directory:
|
| 46 |
+
```bash
|
| 47 |
+
cd my_streamlit_app
|
| 48 |
+
```
|
| 49 |
+
3. Set up a virtual environment (optional but highly recommended):
|
| 50 |
+
```bash
|
| 51 |
+
python -m venv venv
|
| 52 |
+
source venv/bin/activate # On Windows use: venv\Scripts\activate
|
| 53 |
+
```
|
| 54 |
+
4. Install the dependencies:
|
| 55 |
+
```bash
|
| 56 |
+
pip install -r requirements.txt
|
| 57 |
+
```
|
| 58 |
+
5. Run the app:
|
| 59 |
+
```bash
|
| 60 |
+
streamlit run app.py
|
| 61 |
+
```
|
| 62 |
+
6. Open your browser: Visit http://localhost:8501 and enjoy!
|
| 63 |
+
|
| 64 |
+
## ๐น **Usage**
|
| 65 |
+
|
| 66 |
+
- **Navigate the app**: Use the sidebar to explore different sections of the app.
|
| 67 |
+
- **Add tasks**: Manage your tasks using the interactive To-Do List Manager.
|
| 68 |
+
- **Track crypto**: Check real-time (simulated) cryptocurrency prices.
|
| 69 |
+
- **Cast your vote**: Participate in the ongoing voting systemโyour vote matters (well, kinda)!
|
| 70 |
+
- **Visualize data**: Explore the Stanford Policing Dataset using filters and charts to slice and dice the data.
|
| 71 |
+
|
| 72 |
+
## ๐ **Pages Overview**
|
| 73 |
+
|
| 74 |
+
1๏ธโฃ **Introduction Page**
|
| 75 |
+
An introduction to the app and its various features. Sit back, relax, and get ready for the ride!
|
| 76 |
+
|
| 77 |
+
2๏ธโฃ **DataFrame Editor**
|
| 78 |
+
Want to feel like a true data master? Use this page to edit a DataFrame live! Comes pre-loaded with the thrilling professions of Alice, Bob, and Charlie.
|
| 79 |
+
|
| 80 |
+
3๏ธโฃ **Cryptocurrency Price Tracker**
|
| 81 |
+
Tired of checking your crypto portfolio every five seconds? This page lets you simulate real-time crypto pricesโnow you can pretend you're rich without all the stress!
|
| 82 |
+
|
| 83 |
+
4๏ธโฃ **To-Do List Manager**
|
| 84 |
+
A simple and intuitive task manager. Add tasks, check them off, and feel good about accomplishing something (even if it's just pretending to).
|
| 85 |
+
|
| 86 |
+
5๏ธโฃ **Voting System**
|
| 87 |
+
Cast your vote on various options and see live results! Perfect for that "which pizza topping is best" argument.
|
| 88 |
+
|
| 89 |
+
6๏ธโฃ **Weather Data Visualization**
|
| 90 |
+
Visualize temperature and humidity data for two fictional cities (because why not?).
|
| 91 |
+
|
| 92 |
+
7๏ธโฃ **Stanford Policing Dataset Dashboard**
|
| 93 |
+
For the serious data heads. Explore the Stanford Policing Dataset with interactive visualizations and filters, diving into demographics, stop outcomes, and more.
|
| 94 |
+
|
| 95 |
+
8๏ธโฃ **Random Coding Project Generator**
|
| 96 |
+
Stuck in a coding rut? This page will throw random project ideas at youโwhether you're just waking up or in full "Iโm gonna conquer the world" mode. From baby steps to hardcore challenges, there's something for everyone!
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
## ๐ **Folder Structure**
|
| 100 |
+
|
| 101 |
+
```bash
|
| 102 |
+
my_streamlit_app/
|
| 103 |
+
โ
|
| 104 |
+
โโโ app.py # Main Streamlit app
|
| 105 |
+
โโโ pages/ # Contains individual page scripts
|
| 106 |
+
โ โโโ 1_introduction.py
|
| 107 |
+
โ โโโ 2_DataFrame_Editor.py
|
| 108 |
+
โ โโโ 3_Crypto_Tracker.py
|
| 109 |
+
โ โโโ 4_ToDo_List.py
|
| 110 |
+
โ โโโ 5_Voting_System.py
|
| 111 |
+
โ โโโ 6_Weather_Visualization.py
|
| 112 |
+
โ โโโ 7_Stanford_Policing.py
|
| 113 |
+
โโโ requirements.txt # Dependencies
|
| 114 |
+
โโโ README.md # This file!
|
| 115 |
+
โโโ ...
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
## ๐ก **Contributing**
|
| 119 |
+
|
| 120 |
+
Feel like adding more awesomeness to this app? You're in luck! To contribute:
|
| 121 |
+
|
| 122 |
+
1. **Fork the repo**. Yes, claim it as your own (kind of).
|
| 123 |
+
|
| 124 |
+
2. **Create a new branch**:
|
| 125 |
+
```bash
|
| 126 |
+
git checkout -b feature-new-feature
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
3. Make your changes and commit them like a coding rockstar:
|
| 130 |
+
```bash
|
| 131 |
+
git commit -m "Added the coolest feature ever!"
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
4. Push to your branch (because the main branch isn't ready for this level of greatness):
|
| 135 |
+
```bash
|
| 136 |
+
git push origin feature-new-feature
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
5. Open a Pull Request and watch the magic unfold!
|
| 140 |
+
|
| 141 |
+
## ๐ **License**
|
| 142 |
+
|
| 143 |
+
Licensed under the MIT License. See the LICENSE file for more details. If you don't like the license, well... good luck changing it! ๐
|
| 144 |
+
|
| 145 |
+
## ๐ **Contact**
|
| 146 |
+
|
| 147 |
+
Having issues? Suggestions? Feel free to contact your local code monkey (or just send a GitHub issue). For all other inquiries, throw your error logs out the window, because that's how we deal with bugs around here!
|
| 148 |
+
|
| 149 |
+
๐ **Enjoy the Mega Streamlit App and stay productive (or at least make it look like you are)!** ๐
|
app.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title("Welcome to the Mega Streamlit App!")
|
| 4 |
+
st.write("Use the sidebar to navigate to different sections of this app.")
|
pages/1_introduction.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title("Introduction Page")
|
| 4 |
+
st.write("""
|
| 5 |
+
This app showcases various features of Streamlit, including:
|
| 6 |
+
1. DataFrame Editing
|
| 7 |
+
2. Real-Time Cryptocurrency Price Tracking
|
| 8 |
+
3. To-Do List Management
|
| 9 |
+
4. Real-Time Voting System
|
| 10 |
+
5. Weather Data Visualization
|
| 11 |
+
6. Stanford Policing Dataset Dashboard
|
| 12 |
+
7. Random Project Generator
|
| 13 |
+
|
| 14 |
+
Use the sidebar to explore each feature!
|
| 15 |
+
""")
|
pages/2_DataFrame_Editor.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
st.title("Interactive DataFrame Editor")
|
| 5 |
+
|
| 6 |
+
# Sample data
|
| 7 |
+
data = {
|
| 8 |
+
'Name': ['Alice', 'Bob', 'Charlie'],
|
| 9 |
+
'Age': [25, 30, 35],
|
| 10 |
+
'Occupation': ['Engineer', 'Doctor', 'Artist']
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
df = pd.DataFrame(data)
|
| 14 |
+
edited_df = st.data_editor(df)
|
| 15 |
+
st.write("Updated DataFrame:")
|
| 16 |
+
st.write(edited_df)
|
pages/3_Crypto_Tracker.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
st.title("Real-Time Cryptocurrency Price Tracker")
|
| 6 |
+
|
| 7 |
+
# Simulated cryptocurrency prices
|
| 8 |
+
cryptos = ['Bitcoin', 'Ethereum', 'Litecoin', 'Dogecoin', 'Ripple']
|
| 9 |
+
prices = np.random.uniform(100, 50000, len(cryptos))
|
| 10 |
+
|
| 11 |
+
crypto_data = pd.DataFrame({
|
| 12 |
+
'Cryptocurrency': cryptos,
|
| 13 |
+
'Price (USD)': prices
|
| 14 |
+
})
|
| 15 |
+
|
| 16 |
+
# Display the data
|
| 17 |
+
st.write("Cryptocurrency Prices:")
|
| 18 |
+
st.write(crypto_data)
|
| 19 |
+
|
| 20 |
+
# Bar chart visualization
|
| 21 |
+
st.bar_chart(crypto_data.set_index('Cryptocurrency')['Price (USD)'])
|
pages/4_ToDo_List.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
#______________________________________________________________________FOR PERFECTIONISTS________________________________________________________________________________________________________________________________________________________
|
| 4 |
+
|
| 5 |
+
st.title("To-Do List Manager")
|
| 6 |
+
|
| 7 |
+
# Initialize an empty list for tasks and an input session state
|
| 8 |
+
if 'tasks' not in st.session_state:
|
| 9 |
+
st.session_state['tasks'] = []
|
| 10 |
+
if 'new_task_input' not in st.session_state:
|
| 11 |
+
st.session_state['new_task_input'] = ''
|
| 12 |
+
|
| 13 |
+
# Function to handle task submission
|
| 14 |
+
def submit():
|
| 15 |
+
task = st.session_state['new_task_input']
|
| 16 |
+
if task and task not in st.session_state['tasks']:
|
| 17 |
+
st.session_state['tasks'].append(task)
|
| 18 |
+
st.session_state['new_task_input'] = '' # Clear the input field after submission
|
| 19 |
+
|
| 20 |
+
# Text input with submission handler
|
| 21 |
+
st.text_input('Add a new task:', key='new_task_input', on_change=submit)
|
| 22 |
+
|
| 23 |
+
# Display the list of tasks
|
| 24 |
+
st.write("### Your To-Do List:")
|
| 25 |
+
for i, task in enumerate(st.session_state['tasks']):
|
| 26 |
+
if st.checkbox(f"Task {i+1}: {task}"):
|
| 27 |
+
st.session_state['tasks'].remove(task)
|
| 28 |
+
st.rerun() # Refresh the app after removing a task
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
#____________________________OLD STUFF WHERE BUTTONS DON'T WORK PERFECTLY (BUT EVERYTHING ELSE DOES)____________________________________________________________________________________________________________________________________________
|
| 32 |
+
# Initialize an empty list
|
| 33 |
+
#if 'tasks' not in st.session_state:
|
| 34 |
+
# st.session_state['tasks'] = []
|
| 35 |
+
#
|
| 36 |
+
# Input to add a new task
|
| 37 |
+
#new_task = st.text_input('Add a new task:')
|
| 38 |
+
#if st.button('Add Task'): # Maybe needs an additional state for when someone presses Enter?
|
| 39 |
+
# st.session_state['tasks'].append(new_task)
|
| 40 |
+
|
| 41 |
+
# Display the list of tasks
|
| 42 |
+
#st.write("### Your To-Do List:")
|
| 43 |
+
#for i, task in enumerate(st.session_state['tasks']):
|
| 44 |
+
# if st.checkbox(f"Task {i+1}: {task}"):
|
| 45 |
+
# st.session_state['tasks'].remove(task)
|
| 46 |
+
# st.rerun()
|
pages/5_Voting_System.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
|
| 5 |
+
st.title("Voting System")
|
| 6 |
+
|
| 7 |
+
# Predefined voting options
|
| 8 |
+
options = ['Option A', 'Option B', 'Option C', 'Option D']
|
| 9 |
+
|
| 10 |
+
# Voting counts (stored in session state)
|
| 11 |
+
if 'votes' not in st.session_state:
|
| 12 |
+
st.session_state['votes'] = [0] * len(options)
|
| 13 |
+
|
| 14 |
+
# Voting mechanism
|
| 15 |
+
st.write("### Vote for your favorite option:")
|
| 16 |
+
selected_option = st.selectbox('Choose an option:', options)
|
| 17 |
+
|
| 18 |
+
if st.button('Vote'):
|
| 19 |
+
idx = options.index(selected_option)
|
| 20 |
+
st.session_state['votes'][idx] += 1
|
| 21 |
+
st.write(f"Thanks for voting for {selected_option}!")
|
| 22 |
+
|
| 23 |
+
# Display voting results
|
| 24 |
+
results_df = pd.DataFrame({
|
| 25 |
+
'Option': options,
|
| 26 |
+
'Votes': st.session_state['votes']
|
| 27 |
+
})
|
| 28 |
+
|
| 29 |
+
st.write("### Live Voting Results:")
|
| 30 |
+
st.write(results_df)
|
| 31 |
+
|
| 32 |
+
# Bar chart of results
|
| 33 |
+
fig = px.bar(results_df, x='Option', y='Votes', title='Voting Results')
|
| 34 |
+
st.plotly_chart(fig)
|
pages/6_Weather_Visualization.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
|
| 5 |
+
st.title("Weather Data Visualization")
|
| 6 |
+
|
| 7 |
+
# Simulated weather data for two cities
|
| 8 |
+
city_data = pd.DataFrame({
|
| 9 |
+
'City': ['City A', 'City B'],
|
| 10 |
+
'Temperature (ยฐC)': [20, 25],
|
| 11 |
+
'Humidity (%)': [60, 70]
|
| 12 |
+
})
|
| 13 |
+
|
| 14 |
+
# Display the data
|
| 15 |
+
st.write("Weather Data for Two Cities:")
|
| 16 |
+
st.write(city_data)
|
| 17 |
+
|
| 18 |
+
# Bar chart visualization
|
| 19 |
+
fig = px.bar(city_data, x='City', y=['Temperature (ยฐC)', 'Humidity (%)'],
|
| 20 |
+
title='Weather Data Comparison')
|
| 21 |
+
st.plotly_chart(fig)
|
pages/7_Stanford_Policing.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
|
| 6 |
+
# Load the dataset
|
| 7 |
+
@st.cache_data
|
| 8 |
+
def load_data():
|
| 9 |
+
df = pd.read_csv('https://sds-aau.github.io/SDS-master/M1/data/RI-clean.csv.gz', low_memory=False)
|
| 10 |
+
|
| 11 |
+
# Drop unnecessary columns
|
| 12 |
+
df.drop(['id', 'county_name', 'county_fips', 'fine_grained_location', "out_of_state"], axis='columns', inplace=True)
|
| 13 |
+
|
| 14 |
+
# Drop rows with missing crucial data
|
| 15 |
+
df.dropna(subset=['stop_date', 'stop_time', 'driver_gender', 'driver_age'], inplace=True)
|
| 16 |
+
|
| 17 |
+
# Create two datasets: one for search instances and one for the rest
|
| 18 |
+
df_search_type = df[~df['search_type'].isna()]
|
| 19 |
+
df_no_search = df[df['search_type'].isna()]
|
| 20 |
+
|
| 21 |
+
return df_search_type, df_no_search
|
| 22 |
+
|
| 23 |
+
# Load cleaned datasets
|
| 24 |
+
df_search_type, df_no_search = load_data()
|
| 25 |
+
|
| 26 |
+
# Sidebar filters
|
| 27 |
+
st.sidebar.header("Filter the data")
|
| 28 |
+
|
| 29 |
+
# State selector
|
| 30 |
+
states = df_no_search['location_raw'].unique()
|
| 31 |
+
selected_state = st.sidebar.selectbox('Select a Location', states)
|
| 32 |
+
|
| 33 |
+
# Violation selector
|
| 34 |
+
violations = df_no_search['violation'].unique()
|
| 35 |
+
selected_violation = st.sidebar.selectbox('Select a Violation', violations)
|
| 36 |
+
|
| 37 |
+
# Gender multi-select
|
| 38 |
+
selected_genders = st.sidebar.multiselect('Select Genders', df_no_search['driver_gender'].unique(), default=df_no_search['driver_gender'].unique())
|
| 39 |
+
|
| 40 |
+
# Age range slider
|
| 41 |
+
age_range = st.sidebar.slider('Select Age Range', int(df_no_search['driver_age'].min()), int(df_no_search['driver_age'].max()), (18, 60))
|
| 42 |
+
|
| 43 |
+
# Dataset selector
|
| 44 |
+
dataset_option = st.sidebar.radio(
|
| 45 |
+
"Choose Dataset",
|
| 46 |
+
('No Search Dataset', 'Search Type Dataset')
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
# Use selected dataset
|
| 50 |
+
if dataset_option == 'No Search Dataset':
|
| 51 |
+
filtered_data = df_no_search
|
| 52 |
+
else:
|
| 53 |
+
filtered_data = df_search_type
|
| 54 |
+
|
| 55 |
+
# Apply filters
|
| 56 |
+
filtered_data = filtered_data[(filtered_data['location_raw'] == selected_state) &
|
| 57 |
+
(filtered_data['violation'] == selected_violation) &
|
| 58 |
+
(filtered_data['driver_gender'].isin(selected_genders)) &
|
| 59 |
+
(filtered_data['driver_age'].between(age_range[0], age_range[1]))]
|
| 60 |
+
|
| 61 |
+
st.write(f"### Data for location: {selected_state}, Violation: {selected_violation}")
|
| 62 |
+
st.write("Data Preview:", filtered_data.head())
|
| 63 |
+
|
| 64 |
+
### 1. Univariate Analysis ###
|
| 65 |
+
st.subheader('Univariate Analysis')
|
| 66 |
+
|
| 67 |
+
# Driver Age Distribution (Interactive)
|
| 68 |
+
st.write("#### Driver Age Distribution")
|
| 69 |
+
fig_age = px.histogram(filtered_data, x='driver_age', nbins=20, title='Driver Age Distribution')
|
| 70 |
+
st.plotly_chart(fig_age)
|
| 71 |
+
|
| 72 |
+
#st.write("#### Driver Age Distribution")
|
| 73 |
+
#fig_age = px.histogram(filtered_data, x='driver_age', nbins=50, title='Driver Age Distribution')
|
| 74 |
+
#fig_age.update_layout(yaxis_title='Number of Drivers', xaxis_title='Age',
|
| 75 |
+
# xaxis=dict(showgrid=True), yaxis=dict(showgrid=True))
|
| 76 |
+
#st.plotly_chart(fig_age)
|
| 77 |
+
|
| 78 |
+
#fig_age = px.histogram(filtered_data, x='driver_age', nbins=20, title='Driver Age Distribution')
|
| 79 |
+
#fig_age.update_layout(
|
| 80 |
+
# yaxis_title='Number of Drivers',
|
| 81 |
+
# xaxis_title='Age',
|
| 82 |
+
# xaxis=dict(showgrid=True),
|
| 83 |
+
# yaxis=dict(showgrid=True, tickmode='linear', dtick=10) # Set a linear tick mode with a tick interval of 10
|
| 84 |
+
#)
|
| 85 |
+
#st.plotly_chart(fig_age)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
# Violation Distribution
|
| 89 |
+
st.write("#### Distribution of Violations")
|
| 90 |
+
fig_violation = px.histogram(df_no_search, x='violation', title='Violation Distribution')
|
| 91 |
+
st.plotly_chart(fig_violation)
|
| 92 |
+
|
| 93 |
+
### 2. Bivariate Analysis ###
|
| 94 |
+
st.subheader('Bivariate Analysis')
|
| 95 |
+
|
| 96 |
+
# Gender vs Race
|
| 97 |
+
st.write("#### Driver Gender vs Driver Race")
|
| 98 |
+
fig_gender_race = px.histogram(filtered_data, x='driver_gender', color='driver_race', title='Driver Gender vs Driver Race')
|
| 99 |
+
st.plotly_chart(fig_gender_race)
|
| 100 |
+
|
| 101 |
+
# Stop Duration vs Stop Outcome
|
| 102 |
+
#st.write("#### Stop Duration vs Stop Outcome")
|
| 103 |
+
#fig_duration_outcome = px.scatter(filtered_data, x='stop_duration', y='stop_outcome', color='driver_race', title='Stop Duration vs Stop Outcome')
|
| 104 |
+
#st.plotly_chart(fig_duration_outcome)
|
| 105 |
+
st.write("#### Stop Duration vs Stop Outcome (Box Plot)")
|
| 106 |
+
fig_duration_outcome = px.box(filtered_data, x='stop_outcome', y='stop_duration', color='stop_outcome', title='Stop Duration vs Stop Outcome')
|
| 107 |
+
st.plotly_chart(fig_duration_outcome)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
### 3. Multivariate Analysis ###
|
| 111 |
+
st.subheader('Multivariate Analysis')
|
| 112 |
+
|
| 113 |
+
# Gender, Race, and Stop Outcome (Categorical Relationships)
|
| 114 |
+
st.write("#### Driver Gender, Race, and Stop Outcome")
|
| 115 |
+
fig_multivariate = px.parallel_categories(filtered_data, dimensions=['driver_gender', 'driver_race', 'stop_outcome'], title='Gender, Race, and Stop Outcome')
|
| 116 |
+
st.plotly_chart(fig_multivariate)
|
| 117 |
+
|
| 118 |
+
### 4. Time Series Analysis ###
|
| 119 |
+
st.subheader('Time Series Analysis')
|
| 120 |
+
|
| 121 |
+
# Convert 'stop_date' to datetime
|
| 122 |
+
filtered_data['stop_date'] = pd.to_datetime(filtered_data['stop_date'])
|
| 123 |
+
|
| 124 |
+
# Stops Over Time
|
| 125 |
+
st.write("#### Stops Over Time")
|
| 126 |
+
stops_over_time = filtered_data.groupby('stop_date').size().reset_index(name='counts')
|
| 127 |
+
fig_timeseries = px.line(stops_over_time, x='stop_date', y='counts', title='Stops Over Time')
|
| 128 |
+
st.plotly_chart(fig_timeseries)
|
| 129 |
+
|
| 130 |
+
# Stop Duration Over Time
|
| 131 |
+
#st.write("#### Stop Duration Over Time")
|
| 132 |
+
#fig_duration_time = px.line(filtered_data, x='stop_date', y='stop_duration', title='Stop Duration Over Time')
|
| 133 |
+
#st.plotly_chart(fig_duration_time)
|
| 134 |
+
# Aggregate by month and calculate the average stop duration
|
| 135 |
+
|
| 136 |
+
# Plot the monthly average stop duration
|
| 137 |
+
#st.write("#### Monthly Average Stop Duration Over Time")
|
| 138 |
+
#fig_duration_time = px.line(monthly_duration, x='month_year', y='stop_duration', title='Monthly Average Stop Duration Over Time')
|
| 139 |
+
#st.plotly_chart(fig_duration_time)
|
| 140 |
+
# Ensure stop_duration is numeric
|
| 141 |
+
# Convert 'stop_date' to datetime format
|
| 142 |
+
filtered_data['stop_date'] = pd.to_datetime(filtered_data['stop_date'], errors='coerce')
|
| 143 |
+
|
| 144 |
+
# Drop rows where 'stop_date' is NaT
|
| 145 |
+
filtered_data = filtered_data.dropna(subset=['stop_date'])
|
| 146 |
+
|
| 147 |
+
# Extract month-year from the stop_date
|
| 148 |
+
filtered_data['month_year'] = filtered_data['stop_date'].dt.to_period('M')
|
| 149 |
+
|
| 150 |
+
# Group by month_year and stop_duration, and count occurrences
|
| 151 |
+
monthly_duration_counts = filtered_data.groupby(['month_year', 'stop_duration']).size().reset_index(name='counts')
|
| 152 |
+
|
| 153 |
+
# Convert 'month_year' to string for better display in Plotly
|
| 154 |
+
monthly_duration_counts['month_year'] = monthly_duration_counts['month_year'].astype(str)
|
| 155 |
+
|
| 156 |
+
# Plot the stop duration counts over time, grouped by duration category
|
| 157 |
+
st.write("#### Stop Duration Distribution Over Time")
|
| 158 |
+
fig_duration_time = px.line(
|
| 159 |
+
monthly_duration_counts,
|
| 160 |
+
x='month_year',
|
| 161 |
+
y='counts',
|
| 162 |
+
color='stop_duration',
|
| 163 |
+
title='Stop Duration Distribution Over Time',
|
| 164 |
+
labels={'counts': 'Number of Stops', 'month_year': 'Month-Year', 'stop_duration': 'Stop Duration'}
|
| 165 |
+
)
|
| 166 |
+
st.plotly_chart(fig_duration_time)
|
| 167 |
+
|
pages/8_Project_Generator.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Function to load the project ideas from a JSON file
|
| 6 |
+
def load_project_ideas():
|
| 7 |
+
file_path = os.path.join(os.path.dirname(__file__), 'project_ideas.json')
|
| 8 |
+
with open(file_path, 'r') as file:
|
| 9 |
+
return json.load(file)
|
| 10 |
+
|
| 11 |
+
# Function to get a random project based on difficulty
|
| 12 |
+
def get_random_project(project_ideas, difficulty='Beginner'):
|
| 13 |
+
if difficulty not in project_ideas:
|
| 14 |
+
return "Whoa, you just broke the difficulty level! Choose 'Beginner', 'Intermediate', or 'HARDCORE'."
|
| 15 |
+
return random.choice(project_ideas[difficulty])
|
| 16 |
+
|
| 17 |
+
# Streamlit app content directly
|
| 18 |
+
st.title("๐ค Random Coding Project Generator ๐")
|
| 19 |
+
|
| 20 |
+
# Load the project ideas from JSON
|
| 21 |
+
project_ideas = load_project_ideas()
|
| 22 |
+
|
| 23 |
+
# Difficulty level selection with emojis
|
| 24 |
+
difficulty_options = {
|
| 25 |
+
'Beginner ๐ฃ (Simple enough to do in your sleep)': 'Beginner',
|
| 26 |
+
'Intermediate ๐ (You might need coffee for this)': 'Intermediate',
|
| 27 |
+
'HARDCORE ๐ (Prepare for sleepless nights)': 'HARDCORE'
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
difficulty_display = list(difficulty_options.keys())
|
| 31 |
+
selected_display = st.selectbox("Choose your difficulty level:", difficulty_display)
|
| 32 |
+
difficulty = difficulty_options[selected_display]
|
| 33 |
+
|
| 34 |
+
# Button to generate a random project
|
| 35 |
+
if st.button("Surprise me with a project! ๐ฒ"):
|
| 36 |
+
project = get_random_project(project_ideas, difficulty)
|
| 37 |
+
st.write(f"**Your project idea is:** {project}")
|
| 38 |
+
st.write("Good luck, you got this! ๐ช")
|
project_ideas.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Beginner": [
|
| 3 |
+
"Build a basic calculator. Not for your taxes though... ๐",
|
| 4 |
+
"Create a to-do list app that you'll forget to use ๐
",
|
| 5 |
+
"Write a script that renames files. Because 'file_final_v2_really_final.txt' isn't cutting it.",
|
| 6 |
+
"Create a number guessing game. But don't let the computer cheat! ๐คจ",
|
| 7 |
+
"Write a program to reverse a string. Because why not? ๐",
|
| 8 |
+
"Create a basic password generator. No more 'password123'! ๐",
|
| 9 |
+
"Make a temperature converter. Because Celsius and Fahrenheit are *totally* confusing. ๐ฅต๐ฅถ",
|
| 10 |
+
"Build a countdown timer. For when you're boiling the perfect egg. ๐ฅ",
|
| 11 |
+
"Create a quiz game. Test your friends' 'knowledge' of pop culture trivia! ๐",
|
| 12 |
+
"Write a program to check if a number is prime. Let your computer do the math for once! ๐ค",
|
| 13 |
+
"Make a text-based adventure game. Watch your friends get lost in a forest of your imagination! ๐ฒ"
|
| 14 |
+
],
|
| 15 |
+
"Intermediate": [
|
| 16 |
+
"Build a weather app using an API. So you can finally know when to bring an umbrella. โ",
|
| 17 |
+
"Create a personal budget tracker. Because 'winging it' isn't a solid financial strategy. ๐ธ",
|
| 18 |
+
"Develop a command-line address book. The digital age's answer to a Rolodex! ๐๏ธ",
|
| 19 |
+
"Build a web scraper to extract data from a website. Just don't get too *creepy* with it. ๐ธ๏ธ",
|
| 20 |
+
"Create a chatbot using basic NLP techniques. Teach it sarcasm. You know you want to. ๐ค",
|
| 21 |
+
"Make a file encryption program. Because not all secrets are meant to be shared. ๐คซ",
|
| 22 |
+
"Build a note-taking app with search functionality. Like your brain, but better at remembering stuff. ๐ง ",
|
| 23 |
+
"Create a web app using Flask/Django. Yes, you *are* becoming a web developer. ๐ป",
|
| 24 |
+
"Develop a basic image editor. Crop your ex out of those vacation photos! ๐ผ๏ธโ๏ธ",
|
| 25 |
+
"Create a task management app. Watch your productivity rise... or not. ๐คทโโ๏ธ",
|
| 26 |
+
"Write a program that generates and solves Sudoku puzzles. Because solving them isn't hard enough, right? ๐งฉ"
|
| 27 |
+
],
|
| 28 |
+
"HARDCORE": [
|
| 29 |
+
"Develop a multiplayer game with real-time interactions. Say goodbye to your social life! ๐ฎ",
|
| 30 |
+
"Build a machine learning model for image classification. Skynet is one step closer to reality. ๐ค",
|
| 31 |
+
"Create a blockchain-based app. Because what's cooler than decentralized currency? ๐ช",
|
| 32 |
+
"Develop an e-commerce site. Add a shopping cart for impulse buys. ๐๐ธ",
|
| 33 |
+
"Implement your own neural network. Who needs TensorFlow anyway? ๐ค",
|
| 34 |
+
"Create a real-time chat app with WebSockets. Slack better watch out! ๐งโ๐ป๐ฌ",
|
| 35 |
+
"Develop a deep learning model for NLP. Make a computer understand human sarcasm. ๐",
|
| 36 |
+
"Write a distributed system. Because one computer just isn't enough! ๐ฅ๏ธ๐ฅ๏ธ๐ฅ๏ธ",
|
| 37 |
+
"Build your own OS kernel. You think Linux is cool? Try making your own! ๐ง",
|
| 38 |
+
"Develop a trading bot. Watch it make smarter financial decisions than you. ๐๐",
|
| 39 |
+
"Create a 3D rendering engine. Get ready for some *serious* math and graphics. ๐ฅ๏ธ๐น๏ธ"
|
| 40 |
+
]
|
| 41 |
+
}
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.24.1
|
| 2 |
+
pandas==2.0.3
|
| 3 |
+
plotly==5.15.0
|
| 4 |
+
matplotlib==3.7.2
|
| 5 |
+
numpy==1.25.2
|