-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcheckseq.py
More file actions
77 lines (52 loc) · 1.78 KB
/
checkseq.py
File metadata and controls
77 lines (52 loc) · 1.78 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
""" checkseq
Usage:
checkseq.py SEQ_DATA LABEL
checkseq.py -h | --help
Examples:
python3 checkseq.py path/to/scenario-seq.csv solar
Arguments:
SEQ_DATA CSV-file with data for sequences.
LABEL Label to search for in components.
Options:
-h --help Show this screen and exit
"""
__copyright__ = "ZNES"
__license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)"
__url__ = "https://github.com/openego/data_processing/blob/master/LICENSE"
__author__ = "s3pp"
import pandas as pd
from docopt import docopt
def read_csv(**kwargs):
""" Read and handle CSV-file.
Parameters
----------
**kwargs : key word arguments
Arguments passed from command line
Returns
-------
df : pd.DataFrame
DataFrame with data for sequences.
"""
df = pd.read_csv(kwargs['SEQ_DATA'], header=[1, 2, 3, 4], sep=',')
df.dropna(axis=0, how='all', inplace=True)
df.sort_index(inplace=True)
df.drop('label', axis=1, inplace=True)
df = df.astype(float)
df.columns.names = ['label', 'source', 'target', 'value']
return df
def main(**arguments):
print("Reading CSV-file %s" % arguments['SEQ_DATA'])
df = read_csv(**arguments)
# select for label
idx = df.columns.get_level_values('label').str.contains(arguments['LABEL'])
df = df.loc[:, idx]
print("\n\nMaximum value in each sequence with %s." % arguments['LABEL'])
print("------------------------------------------------------")
print(df.max())
print("\n\nSummed up each sequence representing full-loadhours.")
print("------------------------------------------------------")
print(df.sum())
print("Done.")
if __name__ == '__main__':
arguments = docopt(__doc__)
main(**arguments)