-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ae7396
commit c4da892
Showing
22 changed files
with
479,174 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "Python 3", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", | ||
"customizations": { | ||
"codespaces": { | ||
"openFiles": [ | ||
"README.md", | ||
"app.py" | ||
] | ||
}, | ||
"vscode": { | ||
"settings": {}, | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance" | ||
] | ||
} | ||
}, | ||
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'", | ||
"postAttachCommand": { | ||
"server": "streamlit run app.py --server.enableCORS false --server.enableXsrfProtection false" | ||
}, | ||
"portsAttributes": { | ||
"8501": { | ||
"label": "Application", | ||
"onAutoForward": "openPreview" | ||
} | ||
}, | ||
"forwardPorts": [ | ||
8501 | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Python-specific | ||
__pycache__/ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
__pycache__/ | ||
*.db | ||
*.sqlite3 | ||
|
||
# Virtual environments | ||
venv/ | ||
env/ | ||
*.venv/ | ||
env.bak/ | ||
env2/ | ||
env3/ | ||
.pipenv | ||
.Python | ||
*.egg-info | ||
dist/ | ||
build/ | ||
lib/ | ||
bin/ | ||
include/ | ||
|
||
# Compiled Python files | ||
*.pyc | ||
*.pyo | ||
__pycache__/ | ||
|
||
# Logs and backups | ||
*.log | ||
*.swp | ||
*~ | ||
*.bak | ||
*.backup | ||
|
||
# Environment variables | ||
.env | ||
.env.local | ||
.env.*.local | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints/ | ||
|
||
# IDE-specific files | ||
.vscode/ | ||
.idea/ | ||
|
||
# Dependency management files | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Miscellaneous | ||
*.bak | ||
.DS_Store | ||
Thumbs.db |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import streamlit as st | ||
import pandas as pd | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import plotly.express as px | ||
import time | ||
|
||
# ---------------- SETTINGS ------------------- | ||
page_title = 'Laadpalen Project' | ||
# https://www.webfx.com/tools/emoji-cheat-sheet/ | ||
page_icon = ':oncoming_automobile:' | ||
layout = 'centered' | ||
|
||
st.set_page_config( | ||
page_title=page_title, | ||
page_icon=page_icon, | ||
layout=layout, | ||
initial_sidebar_state="expanded", | ||
) | ||
|
||
# ----------------- DATA ---------------------- | ||
from data.OpenChargeMapAPI import realTimeLaadPalenData as df_ocm | ||
from data.OpenDataRDW import rdw_data as df_rdw | ||
from data.laadpaaldata import laadpaal_data as df_lp | ||
# ----------------- PAGES --------------------- | ||
st.title(page_title + ' ' + page_icon) | ||
|
||
st.write(''' | ||
# Introductie | ||
In deze week's data-analyse dashboard, nemen we u graag mee op een informatieve reis door de wereld van elektrische laadpalen en voertuigregistraties in Nederland. Onze analyse is gebaseerd op drie verschillende datasets, elk met unieke inzichten en visualisaties. Op de eerste pagina richten we ons op een diepgaande analyse van de dataset met betrekking tot laadpalen, terwijl de tweede pagina een grondige verkenning biedt van de verdeling van laadpalen in Nederland, gebruikmakend van de open charge data. Op de derde pagina duiken we in de gegevens van de RDW om waardevolle inzichten te verkrijgen over voertuigregistraties en andere relevante informatie. | ||
''') | ||
|
||
# Create a dropdown to select which DataFrame to display | ||
selected_df = st.selectbox("Select a DataFrame", [ | ||
"Laadpalen Tijden", "RDW", "Laadpalen Nederland"]) | ||
|
||
# Display the selected DataFrame | ||
if selected_df == "Laadpalen Tijden": | ||
st.write(df_lp.head()) | ||
st.subheader("Interactive Scatter Plot") | ||
fig = px.scatter(df_lp, x="Started", y="TotalEnergy", | ||
title="Charging Session Energy vs. Start Time") | ||
st.plotly_chart(fig) | ||
|
||
if selected_df == "RDW": | ||
st.write(df_rdw.head()) | ||
progress_text = "Operatie bezig. Even geduld aub." | ||
my_bar = st.progress(0, text=progress_text) | ||
# Assuming you have date columns for both dates | ||
# Assuming you have date columns for both dates | ||
df_rdw['Datum tenaamstelling DT'] = pd.to_datetime( | ||
df_rdw['Datum tenaamstelling DT']) | ||
df_rdw['Datum eerste tenaamstelling in Nederland DT'] = pd.to_datetime( | ||
df_rdw['Datum eerste tenaamstelling in Nederland DT']) | ||
# Extract the month from both dates | ||
df_rdw['Month_Tenaamstelling'] = df_rdw['Datum tenaamstelling DT'].dt.month | ||
df_rdw['Month_EersteTenaamstelling'] = df_rdw['Datum eerste tenaamstelling in Nederland DT'].dt.month | ||
|
||
# Count the number of registrations for each month and date | ||
monthly_counts = df_rdw['Month_Tenaamstelling'].value_counts( | ||
).reset_index() | ||
monthly_counts.columns = ['Month', 'Registrations_Tenaamstelling'] | ||
|
||
monthly_counts_eerste_tenaamstelling = df_rdw['Month_EersteTenaamstelling'].value_counts( | ||
).reset_index() | ||
monthly_counts_eerste_tenaamstelling.columns = [ | ||
'Month', 'Registrations_EersteTenaamstelling'] | ||
|
||
# Merge the two DataFrames on the 'Month' column | ||
merged_counts = monthly_counts.merge( | ||
monthly_counts_eerste_tenaamstelling, on='Month', how='outer').fillna(0) | ||
|
||
for percent_complete in range(100): | ||
time.sleep(0.01) | ||
my_bar.progress(percent_complete + 1, text=progress_text) | ||
time.sleep(1) | ||
my_bar.empty() | ||
|
||
st.write(''' | ||
## Registraties per maand | ||
''') | ||
st.write('- Registrations_Tenaamstelling is de registratie aankomst algemeen van de autos') | ||
st.write('- Registrations_EersteTenaamstelling is de registratie aankomst algemeen van de autos in Nederland') | ||
# Create a grouped bar chart | ||
fig = px.bar( | ||
merged_counts, | ||
x='Month', | ||
y=['Registrations_Tenaamstelling', 'Registrations_EersteTenaamstelling'], | ||
title='Number of Registrations per Month', | ||
|
||
) | ||
|
||
st.plotly_chart(fig) | ||
|
||
if selected_df == "Laadpalen Nederland": | ||
st.write(df_ocm.head()) | ||
# Plot 1: Scatter plot for 'DateCreated' vs | ||
# Convert 'DateCreated' column to datetime | ||
df_ocm['DateCreated'] = pd.to_datetime(df_ocm['DateCreated']) | ||
|
||
# Group the data by date and count the number of rows created on each date | ||
daily_counts = df_ocm.groupby(df_ocm['DateCreated'].dt.date)['DateCreated'].count() | ||
|
||
# Create a line chart | ||
st.subheader("Line Chart: Number of Rows Created Over Time for df_ocm") | ||
fig = px.line(x=daily_counts.index, y=daily_counts.values, labels={"x": "Date", "y": "Number of Rows Created"}) | ||
st.plotly_chart(fig) | ||
|
||
# Plot 2: Bar chart for 'NumberOfPoints' vs 'OperatorInfo.Title' | ||
st.subheader("Bar Chart: NumberOfPoints vs OperatorInfo.Title") | ||
fig2 = px.bar(df_ocm, x="NumberOfPoints", y="OperatorInfo.Title") | ||
st.plotly_chart(fig2) | ||
|
||
# Plot 3: Histogram for 'Connection.PowerKW' | ||
st.subheader("Histogram: Connection.PowerKW") | ||
fig3 = px.histogram(df_ocm, x="Connection.PowerKW") | ||
st.plotly_chart(fig3) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><meta http-equiv="'Content-Type'" content="'text/html;charset=utf-8'" /><title>Minor Data Science - Case week 5-6: Laadpalen en Elektrisch vervoer</title></head><body><table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td colspan=3> </td></tr><tr><td valign="top" width="100%"><font class="title"><strong>Minor Data Science - Case week 5-6: Laadpalen en Elektrisch vervoer</strong></font><br><p class='d2l' style=' margin-left: 40px'><a target="_blank" href="03_ElektrischVervoer.pptx" />1. 03_ElektrischVervoer</a></p><p class='d2l' style=' margin-left: 40px'><a target="_blank" href="Voorbeeld_Binnenhalen_OCM_API.ipynb" />2. Voorbeeld_Binnenhalen_OCM_API</a></p><p class='d2l' style=' margin-left: 40px'><a target="_blank" href="laadpaaldata.csv" />3. laadpaaldata</a></p></td></tr></table></body></html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import requests | ||
|
||
import streamlit as st | ||
|
||
# Request de data en sla de response op in een variabele | ||
|
||
|
||
@st.cache_data # Cache the data to speed up app performance | ||
def load_data(): | ||
data = pd.read_csv("data/laadpalen.csv") | ||
filtered_data = dataclean(data) | ||
return filtered_data | ||
|
||
def dataclean(data): | ||
|
||
# Convert to right datatypes | ||
objects = [ | ||
'OperatorInfo.IsPrivateIndividual', | ||
'OperatorInfo.IsRestrictedEdit', | ||
'UsageType.IsPayAtLocation', | ||
'UsageType.IsMembershipRequired', | ||
'UsageType.IsAccessKeyRequired', | ||
'Connection.ConnectionType.IsDiscontinued', | ||
'Connection.ConnectionType.IsObsolete', | ||
'Connection.StatusType.IsOperational', | ||
'Connection.StatusType.IsUserSelectable', | ||
'Connection.Level.IsFastChargeCapable', | ||
] | ||
for obj in objects: | ||
data[obj] = data[obj].astype('bool') | ||
|
||
return data | ||
|
||
|
||
# Load the data | ||
export = realTimeLaadPalenData = load_data() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pandas as pd | ||
import streamlit as st | ||
|
||
|
||
@st.cache_data # Cache the data to speed up app performance | ||
def load_data(): | ||
data = pd.read_csv("data/car_data.csv") | ||
filtered_data = dataclean(data) | ||
return filtered_data | ||
|
||
|
||
def dataclean(data: pd.DataFrame) -> pd.DataFrame: | ||
# Filter out cars with 'Catalogusprijs' above 200,000 | ||
data = data[data['Catalogusprijs'] <= 200000] | ||
return data | ||
|
||
|
||
# Load the data | ||
export = rdw_data = load_data() |
Oops, something went wrong.