Skip to content
Snippets Groups Projects
Commit 849e0a9c authored by Kalter's avatar Kalter
Browse files

Initial commit of market analysis script

parent 87b4ff68
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
```
%% Cell type:code id: tags:
``` python
def cleanup_manufacturers(df:pd.DataFrame, manufacturer_column = "Hersteller"):
if manufacturer_column not in df:
return
def plot_histogram(df:pd.DataFrame, column_name:str, bins:float|list[float]=20, xlim:list[float]=[None,None]):
if column_name in df.columns:
fig, ax = plt.subplots()
# Plot the histogram
options = {
"bins":bins, "color":'red', "edgecolor":'black',
"histtype":"bar", "rwidth":0.8, "log":False
}
ax.hist(df[column_name], **options)
ax.set_title('Histogram of ' + column_name)
ax.set_xlabel(column_name)
ax.set_ylabel('Frequency')
ax.set_xlim(xlim)
ax.tick_params(axis="x", rotation=45)
plt.show()
else:
print(f"Column '{column_name}' not found in the data.")
return
def plot_barchart(df:pd.DataFrame, column_name:str, num_entries:float|list[float]=None, sort:bool = True, lower_threshold=None):
if column_name in df.columns:
fig, ax = plt.subplots()
value_counts = df[column_name].value_counts()
if sort:
print("Sorting ...")
value_counts = value_counts.sort_values()[::-1]
if sort and num_entries:
print(f"Sorting and choosing first {num_entries} entries ...")
value_counts = value_counts[:num_entries]
if sort and lower_threshold and not num_entries:
print(f"Sorting and cutting all values smaller than {lower_threshold} ...")
value_counts = df[column_name].value_counts().sort_values()[::-1][:num_entries]
value_counts = value_counts[value_counts.values>lower_threshold]
print(value_counts)
categories = value_counts.index
frequencies = value_counts.values
options = {
"color":"red", "edgecolor":"black"
}
ax.bar(categories, frequencies, **options)
ax.set_title('Bar Chart of ' + column_name)
ax.set_xlabel(column_name)
ax.set_ylabel('Frequency')
# Rotate x-tick labels
ax.tick_params(axis='x', rotation=90)
plt.show()
else:
print(f"Column '{column_name}' not found in the data.")
return
```
%% Cell type:code id: tags:
``` python
file_path = "N:\Forschung\EBC1100_ERS_RollOut_KAP_FCN\Data\Literatur\BAFA_Förderfähige_WP_nka.xlsx"
types = {'Hersteller':str, 'Typ ':str, 'Wärme-Nennleistung 35°C [kW]':np.float64, 'ETAs 35 [%]':np.float64,
'Wärme-Nennleistung 55°C [kW]':np.float64, 'ETAs 55 [%]':np.float64, 'Kältemittel':str,
'Netzdienlichkeit':str, 'EE-Anzeige':str}
lw = pd.read_excel(file_path, sheet_name="Luft-Wasser", decimal=",", thousands=".",
dtype=types)
print(lw.columns)
```
%% Output
Index(['Hersteller', 'Typ ', 'Wärme-Nennleistung 35°C [kW]', 'ETAs 35 [%]',
'Wärme-Nennleistung 55°C [kW]', 'ETAs 55 [%]', 'Kältemittel',
'Netzdienlichkeit', 'EE-Anzeige'],
dtype='object')
%% Cell type:code id: tags:
``` python
bins = [*np.arange(0,1000,10), 2000]
print(bins)
#plot_histogram(lw, 'Wärme-Nennleistung 35°C [kW]', bins=bins, xlim=[0,1000])
plot_barchart(lw, 'Hersteller', num_entries=None, lower_threshold=50)
```
%% Output
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 2000]
Sorting ...
Sorting and cutting all values smaller than 50 ...
Hersteller
Mitsubishi Electric Europe B.V 1316
DAIKIN Airconditioning Germany GmbH 221
Trane 204
Buderus - Bosch Thermotechnik GmbH 184
Clivet 174
Panasonic Deutschland 129
AERMEC GmbH 128
FläktGroup 124
ELCO GmbH 97
Toshiba - Beijer Ref Deutschland GmbH 92
Viessmann Werke GmbH & Co KG 88
Bosch Thermotechnik GmbH 82
Samsung Klimatechnik 67
TCL 62
alpha innotec (ait-deutschland GmbH) 62
Swegon Operation srl 60
HYUNDAI 59
NOVELAN (ait-deutschland GmbH) 59
Kampmann 58
S-Klima 56
Inventor 54
Malag&Soltau GmbH / M&S POWER 54
Hitachi - Johnson Controls Hitachi Air\nConditioning Europe SAS 53
Ningbo AUX Electric Co., Ltd. 53
Dimplex - Glen Dimplex Deutschland GmbH 51
Name: count, dtype: int64
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment