Python Pandas - Selecting multiple rows in Pandas DataFrame
Query selection df.query("field_name == 'value'") df.query("field_name == 'value1' & field_name2 == 'value2'") Multi selection df[df['field_name'] == 'value'] df[df['field_name'] == 'value1'][df['field_name'] == 'value2'] df[(df['field_name'] == 'value1') & (df['field_name2'] == 'value2')] .loc selection Selecting some rows and all columns df.loc[df['field_name'] == 'value', :] Selecting some rows and some columns df.loc[df['field_name'] == 'value', ['field_name','field_name2']] Multi selection df.loc[(df['field1'] == 'value1') & (df['field2'] == 'value2'), ['field_name','field_name2']] Regexp selection df.loc[df['field'].str.contains('REGEXP EXPRESSION'),:] df.loc[df['numeric_field'].astype(str).str.contains(...