If I want to create a subset of a DataFrame, based on a condition where a specified column can have multiple specified values, I can do this:
df = df.loc[df[column_name].isin(list_of_acceptable_values)]
If I have a list of column names, what is the best way to create a subset of a DataFrame, based on a condition, which checks if these columns contain a particular value. For example, the list of column names is:
['column_1', 'column_2', 'column_3']
And I want to create a new DataFrame, which only has rows from the initial dataframe that contain 0 in column_1, column_2 or column_3
df[(df[list_of_cols] == 0).any(axis=1)]should work