Jan Meyer
Jan Meyer

Reputation: 3

Remove outer brackets from my list

I have a loop resulting in a list consisting of lists with data(eg: data1=[[t1],[t2],[t3]], however, the number of t's is unknown). This list will be subjected to an ANOVA using this method:

from scipy import stats
f_val, p_val = stats.f_oneway(data1)

this function, however only accepts data in the form

f_val, p_val = stats.f_oneway([t1],[t2],[t3])

my algorithm only yields this form:

f_val, p_val = stats.f_oneway([[t1],[t2],[t3]])

My question: How do I get rid of the outer brackets?

Upvotes: 0

Views: 567

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121486

If you have a variable number of arguments, use the *iterable call notation to apply all elements in iterable as separate arguments:

f_val, p_val = stats.f_oneway(*data1)

Upvotes: 3

Related Questions