pandas selects an example of all rows based on the value of the column
- 2021-01-22 05:15:29
- OfStack
This is as follows:
# Select rows that are equal to some value with ==
df.loc[df['column_name'] == some_value]
# Selects whether the column is a 1 Type value with isin
df.loc[df['column_name'].isin(some_values)]
# The selection of multiple conditions with &
df.loc[(df['column'] == some_value) & df['other_column'].isin(some_values)]
# Select row records that do not equal some value with ! =
df.loc[df['column_name'] != some_value]
# isin return 1 Serial value , If you want to choose a value that does not meet this condition ~
df.loc[~df['column_name'].isin(some_values)]