I'm trying to select rows from a pandas DataFrame based on multiple conditions. The code looks like this:
row = videos_train_df[
(videos_train_df['pid1']==pid1)
&(videos_train_df['pid2']==pid2)
&(videos_train_df['vid'] ==vid)]
Is there any better way (in terms of code readability) to do the same thing?
df.queryis a nice way to avoid reusing thevideos_train_dfvariable name in the condition. Plus there could be 100 conditions instead of 3 conditions and then passing a string to df.query is easier to work with