import pandas as pd
df=pd.DataFrame({"A":[1,2,3],"B":[10,20,30]})
print(df.to_markdown())
A | B | |
---|---|---|
0 | 1 | 10 |
1 | 2 | 20 |
2 | 3 | 30 |
def fnc(dt):
return dt["A"]+dt["B"]
df["C"]=df.apply(lambda dt : fnc(dt) ,axis=1 )
print(df.to_markdown())
A | B | C | |
---|---|---|---|
0 | 1 | 10 | 11 |
1 | 2 | 20 | 22 |
2 | 3 | 30 | 33 |
Recommended Posts