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?
I will do all
after eq
new = df[df[['pid1','pid2','vid']].eq([pid1,pid2,vid]).all(1)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.