0
Can I calculate this example : 14+165, 18+180 etc
import pandas as pd data = { 'ages': [14, 18, 24, 42], 'heights': [165, 180, 176, 184] } df = pd.DataFrame(data) print(df)
4 Answers
+ 6
Without panda
data = {
'ages': [14, 18, 24, 42],
'heights': [165, 180, 176, 184]
}
for ( age, height ) in zip( data['ages'], data['heights'] ):
print( f"{age} + {height} = {age + height}" )
+ 3
Using pandas, you can simply use the '+' operator to add two columns of a data frame. So in your code, you can simply do
df["ages"] + df["heights"]
+ 1
Thanks
+ 1
No problem đ