-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello_world.py
63 lines (52 loc) · 1.57 KB
/
hello_world.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
data = pd.read_csv("data/data-sonne.csv", delimiter=',')
data['timestampLocal'] = pd.to_datetime(data.timestampLocal)
data.dropna()
feiertage = pd.read_csv("additional_data/feiertage.csv")
# sonne = pd.read_csv("additional_data/sonnenstunden.csv")
# sonne.set_index(sonne.date, inplace=True)
#
# def getSun(date):
# if pd.notnull(date):
# datum = date.strftime("%m-%d")
# datum2 = date.strftime("%Y-%m-%d")
# daten = sonne.loc[datum, :]
#
# start = daten.loc["start"]
# end = daten.loc["end"]
#
# start = datetime.strptime(datum2 + " " + start, '%Y-%m-%d %I:%M:%S %p')
# end = datetime.strptime(datum2 + " " + end, '%Y-%m-%d %I:%M:%S %p')
# if start < date < end:
# #print(date)
# return 1
# else:
# #print(date)
# return 0
# else:
# #print('fehler')
# return -1
#
#
# data["sun"] = data["timestampLocal"].apply(getSun)
# data.to_csv('data/data-sonne.csv')
unique_dates = feiertage["Datum"].unique()
def isHoliday(date):
if pd.notnull(date):
datum = date.strftime("%Y-%m-%d")
is_weekend = date.isoweekday() >= 6
is_holiday = datum in unique_dates
if is_holiday:
return 1
elif is_weekend:
return 2
else:
return 0
else:
return -1
data["holiday"] = data["timestampLocal"].apply(isHoliday)
data.to_csv('data/data-sonne-feiertage.csv')