Answers for "add a column while iterating rows pandas"

0

add a column while iterating rows pandas

for idx, row in df.iterrows():
    if  df.loc[idx,'Qty'] == 1 and df.loc[idx,'Price'] == 10:
        df.loc[idx,'Buy'] = 1
Posted by: Guest on August-17-2021
0

add a column while iterating rows pandas

mask = (df['Qty'] == 1) & (df['Price'] == 10)
df.loc[mask, 'Buy'] = 1
Posted by: Guest on August-17-2021

Code answers related to "add a column while iterating rows pandas"

Python Answers by Framework

Browse Popular Code Answers by Language