filtering based on values python code example
Example 1: pandas slice based on column value
df.loc[df['column_name'] == some_value]
Example 2: filter data in a dataframe python on a if condition of a value
python by Testy Toucan
on May 22 2020 Donate
Comment
df_filtered = df.loc[df['column'] == value]
Example 3: pandas filter rows by value in list
df.loc[df['col name'].isin(ls_conditions)]
Example 4: only keep rows of a dataframe based on a column value
df.loc[(df['column_name'] >= A) & (df['column_name'] <= B)]