Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (50.2k points)

image

In the above dataframe, I would like to get the average of each row. currently, I am doing this:

df.mean(axis=0)

However, this does away with the Region column as well. how can I compute mean and also retain Region column

1 Answer

0 votes
by (107k points)

You can define a new column. You also need to estimate the mean value along the rows, so use axis=1, refer the following code:

image

If you are interested in learning Pandas and want to become an expert in Python Programming, then check out this Python Course and upskill yourself.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...