I have a dataframe y:
Table 1: Main dataframe y
| Numero | Date | location |
|---|---|---|
| 1111 | 01/11/2009 | 0065;686006;AN |
| 1111 | 01/11/2009 | 0065;686006;P6 |
| 1111 | 05/11/2009 | 0065;686675;1P |
| 1111 | 05/11/2009 | 0065;688575;RE |
| 1111 | 06/11/2009 | 0065;686675;1P |
| 1111 | 05/11/2009 | 0065;686006;AN |
| 5654 | 15/11/2009 | 0065;686675;1P |
| 5654 | 15/11/2009 | 0065;565845;2K |
| 5654 | 26/11/2009 | 0065;154224;5O |
| 4581 | 05/12/2009 | 0065;686006;AN |
Table 2: Conditions dataframe cond
| Info 1 | Info 2 |
|---|---|
| 686006;AN | 686006;P6 |
| 565845;2K | 686675;1P |
So I want to create a new table with the same numero in same date pass through two points "686006;AN and 686006;P6" or "565845;2K and 686675;1P".
Desired output:
| Numero | Date | location |
|---|---|---|
| 1111 | 01/11/2009 | 0065;686006;AN |
| 1111 | 01/11/2009 | 0065;686006;P6 |
| 5654 | 15/11/2009 | 0065;686675;1P |
| 5654 | 15/11/2009 | 0065;565845;2K |
dr = y.groupby('Numero')
my_set = []
for a, b in itertools.combinations(y['Date'], 2):
if op.eq(a,b) == True:
for elem, group in dr:
for j in range(len(cond)):
if group['location'].str.contains(cond['Info 1'][j]).any() and group['location'].str.contains(cond['Info 2'][j]).any():
my_set.append(elem)
my_train
data_= y.loc[y['Numero'].isin(my_train)]
print(data_)
But it doesn't work because large data so out memories and it doesn't print the date and only the value containing the info but all the values of that element.
THANK YOU SO MUCH!!!!!