I am a very beginner of Python.
The goal is to slice the column of DataFrame('incen') which contains specific device codes...
But the device codes keep changed, so I made it into a list('device_code').
I tried to use for loop like this way:
for a in device_code:
incen[(incen.device_name.str.contains(a) == True)]
However, it couldn't be merged into one DataFrame.
So I solved it into this way which is super inefficient:
incen[(incen.device_name.str.contains(device_code[0]) == True)]|incen[(incen.device_name.str.contains(device_code[1]) == True)]|incen[(incen.device_name.str.contains(device_code[2]) == True)]|incen[(incen.device_name.str.contains(device_code[3]) == True)]
...and so on...
Let me understand how to use logical 'or' and for loop at the same time. Thanx.