I can use .map(func)
on any column in a df, like:
df=DataFrame({'a':[1,2,3,4,5,6],'b':[2,3,4,5,6,7]})
df['a']=df['a'].map(lambda x: x > 1)
I could also:
df['a'],df['b']=df['a'].map(lambda x: x > 1),df['b'].map(lambda x: x > 1)
Is there a more pythonic way to apply a function to all columns or the entire frame (without a loop)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…