Skip to content
Advertisement

T-test in Pandas

If I want to calculate the mean of two categories in Pandas, I can do it like this:

JavaScript

I have a lot of data formatted this way, and now I need to do a T-test to see if the mean of cat1 and cat2 are statistically different. How can I do that?

Advertisement

Answer

it depends what sort of t-test you want to do (one sided or two sided dependent or independent) but it should be as simple as:

JavaScript

it returns a tuple with the t-statistic & the p-value

see here for other t-tests http://docs.scipy.org/doc/scipy/reference/stats.html

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement