Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #column #corresponds #average #columns #pandas
ADD COMMENT
Topic
Name
7+2 =