-
Notifications
You must be signed in to change notification settings - Fork 1
/
time span.txt
49 lines (43 loc) · 1.97 KB
/
time span.txt
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
import pandas as pd
import numpy as np
#Time span
df = pd.read_csv(r'C:\Users\ahmed\Desktop\Movie internship\file\50 Actors.csv',usecols=['years','actor1','actor2','actor3','actor4','actor5','actor6','actor7','actor8','actor9','actor10','actor11','actor12','actor13','actor14','actor15','actor16','actor17','actor18','actor19','actor20','actor21','actor22','actor23','actor24','actor25','actor26','actor27','actor28','actor29','actor30','actor31','actor32','actor33','actor34','actor35','actor36','actor37','actor38','actor39','actor40','actor41','actor42','actor43','actor44','actor45','actor46','actor47','actor48','actor49','actor50','actor51'])
#print(df)
actor = df.values
#print(actor)
count = []
def timeSpan(x):
w=0
for i in range(len(x)):
for j in range(len(x[i])):
z = x[i][j]
y = x[i][len(x[i])-1]
f = False
n=(len(x))-1
while(f == False & n <= (len(x))):
if(n<0):
break
# for n in range(len(x)-1,0,-1):
#for m in range(len(x[n])-1):
m=0;
while( m <= (len(x[n])-1)):
if z != x[n][m]:
w+=1
f = False
else :
count.append(str(z)+":"+str(y)+":"+str(x[n][len(x[m])-1]))
print(count)
f = True
break
m+=1
n -= 1
return count
output = []
output = timeSpan(actor)
finalResult = []
finalResult = list( dict.fromkeys(output) )
#print(finalResult)
with open(r'C:\Users\ahmed\Desktop\Movie internship\file\timespan no duplicate.txt', 'w',encoding="utf-8") as f:
for item in finalResult:
f.write("%s\n" % item)
# ------------------------------