In [48]:
import time
t1 = time.time()
In [49]:
t2 = time.time()
print(t2-t1)
In [10]:
str1 = ' a b c '
str1.replace(' ','')
Out[10]:
In [7]:
import numpy as np
a = np.array([1, 2, 3, 4])
b = np.array([2, 4, 6, 8])
c=set(a).intersection(b)
c
Out[7]:
In [28]:
for i in enumerate(b):
print(i)
In [26]:
a = [1, 2, 3, 4]
b = [2, 4, 6, 8]
[i for i, value in enumerate(b) if value in a]
Out[26]:
In [8]:
[np.where(a == e) for e in c if np.where(a ==e)]
Out[8]:
In [9]:
[np.where(b == e) for e in c if np.where(b ==e)]
Out[9]:
In [10]:
x=[1,2,3,4,5]
y=[1,1,2,3,4]
set(x)
Out[10]:
In [11]:
set(y)
Out[11]:
In [18]:
c=np.intersect1d(x,y)
In [19]:
[np.where(x == e) for e in c if np.where(x ==e)]
Out[19]:
In [21]:
a_list = []
for e in c:
if np.where(x==e):
a_list.append(np.where(x==e))
In [22]:
a_list
Out[22]: