I am sure this is simple but I am still learning python. I need help figuring out how to iterate over columns in a pandas dataframe and run the pingouin analysis for each. As of now, I can run
pg.anova(data=df, dv='variable1', between='Group', detailed=True)
While I get the results that I want, I have 180 variables and so to be able to automate this would go a long way. If there were a way to also add the p-value results as a vector to the dataframe, I would be most grateful. Alternatively, being able to save the results in another file will be fine as long as I can tie the anova results to each variable name.
The results from anova are pandas Dataframes, so it's easy to append these into a single DataFrame, you only have to create a new variable to identify each dependent variable:
The DataFrame
df_results
contains all the Anova results and the variabledv
help you to identify the dependent variable. The results are also exported to Excel. If you want only the p-values and dep variable, then you can filter this df: