-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
59 lines (49 loc) · 1.35 KB
/
utils.py
File metadata and controls
59 lines (49 loc) · 1.35 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
def split_comma(ctx, params, value):
return value.split(',') if value else []
def valid_columns(df, columns):
for c in columns:
if c not in df:
print()
print(f'unknown column: {c}')
cols = ','.join(map(repr, df.columns))
print(f'available columns: {cols}')
exit(-1)
def get_named_argument(function, name, args, kwargs):
import inspect
index = inspect.getargspec(function).args.index(name)
if index < len(args):
return args[index]
else:
return kwargs[name]
def groupby(df, groups):
if groups:
return df.groupby(groups, group_keys=False, as_index=False)
else:
return df.groupby(['_'], group_keys=False, as_index=False)
class color_fg:
black = '\033[30m'
red = '\033[31m'
green = '\033[32m'
orange = '\033[33m'
blue = '\033[34m'
purple = '\033[35m'
cyan = '\033[36m'
lightgrey = '\033[37m'
darkgrey = '\033[90m'
lightred = '\033[91m'
lightgreen = '\033[92m'
yellow = '\033[93m'
lightblue = '\033[94m'
pink = '\033[95m'
lightcyan = '\033[96m'
end = '\033[0m'
class color_bg:
black = '\033[40m'
red = '\033[41m'
green = '\033[42m'
orange = '\033[43m'
blue = '\033[44m'
purple = '\033[45m'
cyan = '\033[46m'
lightgrey = '\033[47m'
end = '\033[0m'