Select row from a DataFrame based on values in a column in pandas -
df.loc[df['column_name'] == some_value]
selects data row or rows in dataframe given specified column.
what equivalent if need specify 'row name' ?
if understand correctly, can pass index directly loc
:
example:
df b group abc 6 9 abc 3 12 abc 5 56 def 8 32 gfd 4 65 uio 2 87 def 1 31 poi 8 2 fgb 3 3 df.loc['abc'] b group abc 6 9 abc 3 12 abc 5 56
Comments
Post a Comment