-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeslice_analysis.py
38 lines (28 loc) · 1011 Bytes
/
timeslice_analysis.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
import datetime
import pandas as pd
import sklearn
import numpy as np
from scipy.spatial.distance import pdist
from sklearn.cluster import DBSCAN, KMeans
import seaborn as sns
import matplotlib.pyplot as plt
from scipy import stats
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
from sklearn.preprocessing import normalize
from utils.io import read_enbw_dataset
TOTAL_DAYS_YEAR = 365
data = read_enbw_dataset('data/hackathon_EnBW_smart_meter_data_30_hh.csv')
groups = data.groupby('id')
group = groups.get_group(9)
timeslice = group.iloc[3600:8000, :]
timeslice.dropna(inplace=True)
timeslice.value.plot()
timeslice.set_index(timeslice.timestampLocal, inplace=True)
timeslice = timeslice.resample('1H').mean()
timeslice_groups = timeslice.groupby(lambda x: x.dayofyear)
plt.figure()
timeslice['value'].rolling(window=100).mean().plot()
plt.figure()
timeslice.value.plot()
quantiles = timeslice.quantile([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.6, 0.8, 0.9, 1])