Skip to content
Advertisement

Apply T-Test test per group

I have dataframe like this:

JavaScript

And i want to calculate p-value from T-Test for each variable between groups. I can manually calculate each p-value like this:

JavaScript

So the question is how can i get a result dataframe like shown below for all variables automatically?

JavaScript

Advertisement

Answer

There are several ways, the core idea is to use groupby on the variable.

Here is one example:

JavaScript

output:

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