I have a dataframe
. I want to replace values of all columns of some rows to a default value. Is there a way to do this via pandas apply
function
Here is the dataframe
import pandas as pd
temp=pd.DataFrame({'a':[1,2,3,4,5,6],'b':[2,3,4,5,6,7],'c':['p','q','r','s','t','u']})
mylist=['p','t']
How to replace values in columns a
and b
to default value 0,where value of column c
is in mylist
Is there a way to do this using pandas functionality,avoiding for loops