-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabel_data.py
More file actions
48 lines (38 loc) · 1.42 KB
/
Copy pathlabel_data.py
File metadata and controls
48 lines (38 loc) · 1.42 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
import pandas as pd
high = ["high", "severe", "critical", "urgent", "highest", "top", "mvp", "emergency"]
medium = ["medium", "normal", "middle", "moderate", "med"]
low = ["low"]
def normalize_priority(label):
if len([x for x in high if x in label]) > 0:
return 1
elif len([x for x in medium if x in label]) > 0:
return 0
elif len([x for x in low if x in label]) > 0:
return -1
else:
return None
def normalize_data(data):
data = data.copy()
data['priority'] = data['priority'].map(normalize_priority)
return data[data['priority'].notnull()]
def pivot_labels(data):
data = data.copy()
data['other_labels'] = data['other_labels'].str.split(',')
data = data.explode('other_labels')
data['other_labels'] = data['other_labels'].str.strip()
data.drop(data['other_labels'] == '', axis=0)
data['dummy'] = 1
print(data.columns)
print(data.shape)
data = data.pivot_table(values='dummy',
columns=['other_labels'],
index=['issue_title', 'body', 'priority'])
data.reset_index(level=data.index.names, inplace=True)
return data
def main():
data = pd.read_csv("github-issues.csv")
normalized_data = normalize_data(data)
normalized_label_data = pivot_labels(normalized_data)
normalized_label_data.to_csv("normalized-github-issues.csv", index=False)
if __name__ == '__main__':
main()