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)

30th Mar 2021, 3:13 AM
Yohanes Prasdya
Yohanes Prasdya - avatar
4 ответов
+ 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}" )
30th Mar 2021, 4:13 AM
Ipang
+ 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"]
30th Mar 2021, 4:49 AM
XXX
XXX - avatar
+ 1
Thanks
30th Mar 2021, 4:26 AM
Yohanes Prasdya
Yohanes Prasdya - avatar
+ 1
No problem 👌
30th Mar 2021, 4:27 AM
Ipang