Say if I have a df
with columns A,B,C,D
. I wanted to copy df
to df1
columns A
and B
only based on a condition column C = 1
.
Thanks for your help!!
Thanks Scott for your reply.
The first option worked!!!
The second option is giving error 'expr must be a string to be evaluated, <class 'pandas.core.series.Series'> given Code : temp1 = df[['Music', 'Pop', 'Rock']].query(df.Rock == '1.0')
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.