-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpair_creator.py
46 lines (40 loc) · 1.31 KB
/
pair_creator.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
39
40
41
42
43
44
45
46
import numpy as np
import pandas as pd
import csv
import random
tweets_all=np.load("All-tweets-array.npy",allow_pickle=True)
paired_users=[]
total_length=0
with open("data.csv") as csvfile:
reader = csv.reader(csvfile) # change contents to floats
seesv=list(reader)
for x in range(2):
rand=random.randint(0,total_length)
id=seesv[rand][0]
follows=seesv[rand][10:120]
breaker=False
for a in range(total_length):
if breaker:
break
friend_id=seesv[a][0]
if friend_id in follows and id in seesv[a][10:120]:
tweets_all[rand][0]="True"
tweets_all[a][0]="True"
temp=[tweets_all[rand],tweets_all[a]]
paired_users.append(temp)
breaker=True
for x in range(2):
rand=random.randint(0,total_length)
id=seesv[rand][0]
follows=seesv[rand][10:120]
rand2=random.randint(0,total_length)
friends_id=seesv[rand2][0]
if friend_id in follows and id in seesv[rand2][10:120]:
tweets_all[rand][0]="True"
tweets_all[a][0]="True"
else:
tweets_all[rand][0]="False"
tweets_all[a][0]="False"
temp=[tweets_all[rand],tweets_all[a]]
paired_users.append(temp)
np.save("All-tweets-paired-array",paired_users, allow_pickle=True)