-
Notifications
You must be signed in to change notification settings - Fork 0
/
reindex_A.py
29 lines (23 loc) · 1.29 KB
/
reindex_A.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
import pandas as pd
data_path = ''
node_feat_csv = pd.read_csv(data_path + '/node_features.csv', header=None,
names=['idx', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8'])
node_idx = node_feat_csv['idx'].values
node_map = {}
for i, idx in enumerate(node_idx):
node_map[idx] = i
node_feat_csv['idx'] = node_feat_csv['idx'].map(node_map)
node_feat_csv.to_csv(data_path + '/node_features_reindex.csv', index=False, header=None)
edge_csv = pd.read_csv(data_path + '/edges_train_A.csv', header=None, names=['u', 'i', 'idx', 'ts'])
edge_csv['u'] = edge_csv['u'].map(node_map)
edge_csv['i'] = edge_csv['i'].map(node_map)
edge_csv.to_csv(data_path + '/edges_train_A_reindex.csv', index=False, header=None)
edge_csv = pd.read_csv(data_path + '/input_A_initial.csv', header=None,
names=['u', 'i', 'idx', 'ts1', 'ts2', 'label'])
edge_csv['u'] = edge_csv['u'].map(node_map)
edge_csv['i'] = edge_csv['i'].map(node_map)
edge_csv.to_csv(data_path + '/input_A_initial_reindex.csv', index=False, header=None)
edge_csv = pd.read_csv(data_path + '/input_A.csv', header=None, names=['u', 'i', 'idx', 'ts1', 'ts2'])
edge_csv['u'] = edge_csv['u'].map(node_map)
edge_csv['i'] = edge_csv['i'].map(node_map)
edge_csv.to_csv(data_path + '/input_A_reindex.csv', index=False, header=None)