Skip to content
Snippets Groups Projects
Commit 9f994d7f authored by root's avatar root
Browse files

Added example 11 Power Plant Monitoring

parent 738aeda5
No related branches found
No related tags found
No related merge requests found
11_PowerPlantRemoteMonitoring/boxplot.png

194 KiB

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# read the downloaded csv file
df = pd.read_csv("opendata-kfue-odl_7t.csv", sep=';', decimal=',', on_bad_lines='warn', encoding="ISO-8859-1")
# Get the rows for the abbreviation to name matching
df_colnames = df.take(range(171,255))
# drop all columns except the first
df_colnames.drop(columns=df.columns[1:], inplace=True)
# Create a dictionary to translate from abbreviation to the actual name
col_dict = {}
for row in df_colnames.iloc[:,0]:
place_abbreviation = row[:12]
# We are not interested in Weather data so we dont need them in the dictionary
if "MET" not in place_abbreviation and "TIS" not in place_abbreviation:
place = str(row[15:65]).strip().removeprefix("KF"+ chr(ord("Ü"))+"-Sonde")
# print(place_abbreviation, " = ", place)
col_dict[place_abbreviation] = place
# Extract the data rows and drop the last column because it is an empty column
df_data = df.take(range(1, 169))
df_data.drop(columns=df.columns[-1], inplace=True)
# Remove the unused columns (everything except Radiation)
for col in df_data.columns:
if "MET" in col or "TIS" in col:
df_data.drop(columns=col, inplace=True)
elif col != "Datum/Uhrzeit":
# The values are in scientific notation (7,095e-02) and need to be converted
# Convert all values to strings where the ',' is replaced by the decimal indicator '.'
# Further use pandas library to convert them to numeric values
# the method apply uses a given function on every element of the specified column of the dataframe
df_data[col]= df_data[col].apply(lambda x: str(x).replace(",", ".")).apply(pd.to_numeric, errors='coerce')
# Drop all columns where all values consist of NaN
df_data.dropna(axis=1, how='all', inplace=True)
# Create a Boxplot
df_data.drop(columns=df.columns[0], inplace=True)
plt.figure(figsize=(18,18))
plt.title("Power plant monitoring")
plt.boxplot(df_data.iloc[:,1:], tick_labels=[col_dict[x] for x in df_data.columns[1:]])
plt.xticks(rotation=90)
# \u00B5 is equal to the micro character
plt.ylabel("\u00B5S/h")
plt.grid()
plt.savefig("boxplot.png")
This diff is collapsed.
...@@ -10,4 +10,5 @@ Example # | Name | Description | Input format | Output | Source ...@@ -10,4 +10,5 @@ Example # | Name | Description | Input format | Output | Source
05 | Park bench map | Show a map of all park benches in the city of Norderstedt | SHP (shape file) | Table, Open Street Map overlay | https://opendata.schleswig-holstein.de/dataset/parkbanke 05 | Park bench map | Show a map of all park benches in the city of Norderstedt | SHP (shape file) | Table, Open Street Map overlay | https://opendata.schleswig-holstein.de/dataset/parkbanke
06 | Tax office map | Create a formatted HTML and map containing all tax offices in Schleswig-Holstein | RDF | HTML table, Open Street Map overlay | https://opendata.schleswig-holstein.de/dataset/finanzamter-2024-01-28 06 | Tax office map | Create a formatted HTML and map containing all tax offices in Schleswig-Holstein | RDF | HTML table, Open Street Map overlay | https://opendata.schleswig-holstein.de/dataset/finanzamter-2024-01-28
08 | Water height diagram | Create a line diagram of the water height of the Stoer near Willenscharen for 2023 | CSV | Diagram (PNG) | https://opendata.schleswig-holstein.de/dataset/wasserstand-pegel-willenscharen-stor1 08 | Water height diagram | Create a line diagram of the water height of the Stoer near Willenscharen for 2023 | CSV | Diagram (PNG) | https://opendata.schleswig-holstein.de/dataset/wasserstand-pegel-willenscharen-stor1
10 | Redispatch SH-Netz AG | Show a scatter plot of the number of EEG plants of a commune and the amount of time the electricity supply needed to be reduced | CSV | Scatterplot (PNG) | https://opendata.schleswig-holstein.de/dataset/redispatch-2022-08 10 | Redispatch SH-Netz AG | Show a scatter plot of the number of EEG plants of a commune and the amount of time the electricity supply needed to be reduced | CSV | Scatterplot (PNG) | https://opendata.schleswig-holstein.de/dataset/redispatch-2022-08
\ No newline at end of file 11 | Power plant monitoring | Show a box plot (mean, variance, outliers) of the measures of genitron stations at different locations over a one week time window | CSV | Boxplot (PNG) | https://opendata.schleswig-holstein.de/dataset/kfu-messwerte-2024-07-29
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment