Intellipaat Back

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

I am trying to do a naive Bayes and after loading some data into a dataframe in Pandas, the describe function captures the data I want. I'd like to capture the mean and std from each column of the table but am unsure on how to do that. I've tried things like:

df.describe([mean])

df.describe(['mean'])

df.describe().mean

None are working. I was able to do something similar in R with summary but don't know how to do in Python. Can someone lend some advice?

1 Answer

0 votes
by (41.4k points)

Try the below line of code:

df.describe(include='all').loc['mean']

And if you want mean and std both then write the below code:

df.describe()[['mean', 'std']].

If you wish to learn more about how to use python for data science, then go through this data science python course by Intellipaat for more insights.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...