Reputation: 3928
I have a dataframe df
with a MultIndex like this:
df.index.levels
FrozenList([[u'params', u'pvals', u'statistics', u'std'], [u'x1', u'x2', u'x3', u'x4', u'Hx5', u'adj_r2', u'r2', u'_f_test']])
You can guess that df
contains an OLS output. Is there a pandas
function that I can use to count how many times a number in the index pvals
for each x1 x2 ... x5
is less than 0.05?
Upvotes: 0
Views: 448
Reputation: 32212
(df.ix["pvals"].ix[["x1", "x2", "x3", "x4", "x5"]] < 0.05).sum()
The trick is here that Python converts True
to 1 and False
to 0 when you use them in an arithmetic context.
Upvotes: 1