7

I have a problem. I want to run the scipy.stats f_oneway() ANOVA in a script that loads a data-archive containing groups with numpy arrays like so:

archive{'group1': array([ 1, 2, 3, ..., ]),
        'group2': array([ 9, 8, 7, ..., ]),
        ...}

Now my problem is that the number of groups is not fixed for different data-archives. In other words, I don't know beforehand, how many groups there are in an archive (and also not necessarily what their names are).

The scipy implementation of a oneway ANOVA only accepts comma delimited arrays as input like so:

a = array([ 1, 2, 3, ..., ])
b = array([ 9, 8, 7, ..., ])
c = array([ 5, 6, 4, ..., ])

scipy.stats.f_oneway(a, b, c)

I tried to give it lists, tuples, multidimensional arrays all without success. So presently, the only way I can use this ANOVA implementation is by manually entering the group variables each time which effectively makes it impossible to run this in a script. I am wondering if one of you has an idea how to solve this or how to avoid these very specific data format requirements of f_oneway().

nneonneo
  • 171,345
  • 36
  • 312
  • 383
surchs
  • 463
  • 1
  • 7
  • 11

1 Answers1

16

I suppose you should try:

scipy.stats.f_oneway(*archive.values())
Michael
  • 7,316
  • 1
  • 37
  • 63