Answers for "calculate the average column based on two other columns python"

1

get a column that corresponds to the average of two columns pandas

df['avg'] = df.mean(axis=1)

       Monday  Tuesday  Wednesday        avg
Mike       42      NaN         12  27.000000
Jenna     NaN      NaN         15  15.000000
Jon        21        4          1   8.666667
Posted by: Guest on May-09-2021
0

pandas new column average of other columns

col = df.loc[: , "salary_1":"salary_3"]
df['salary_mean'] = col.mean(axis=1)
Posted by: Guest on March-26-2021

Code answers related to "calculate the average column based on two other columns python"

Python Answers by Framework

Browse Popular Code Answers by Language