I want to drop rows from a dataframe, based on the condition that the value of a specific column is in a list. If this is not the case I want the row to be dropped.
Do you have any suggestions? Thanks in advance
As an example, if the value in column 'C' is not inside the list l, I want to drop the entire row
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randint(0,100,size=(20, 4)), columns=list('ABCD')) l = [4, 6, 23, 45, 79]