0

I have a results_table as below:

               sum_sq         df           F            PR(>F)
    ABC         4.13          4.0        337.2           2.53
    Residual    4.45         110.0       NaN             NaN

What I am trying to do to print out 'test positive' only if PR(>F) is greater than 1. I tried the below:

if results_table.loc[[1],'PR(>F)'] > 1:
    print('test positive')

But I get the below error:

KeyError: "None of [Int64Index([1], dtype='int64')] are in the [index]"

Could someone please help me with how to do this?

2 Answers 2

1

If you are actually trying to access a single value then this

if results_table.loc['ABC', 'PR(>F)'] > 1:
    print('test positive')

or better this (.at[] is optimised for this kind of access)

if results_table.at['ABC', 'PR(>F)'] > 1:
    print('test positive')

should work.

The brackets here .loc[[1], 'PR(>F)'] or here .loc[['ABC'], 'PR(>F)'] make the result a series.

Sign up to request clarification or add additional context in comments.

Comments

0

With loc use should row/col names

if results_table.loc[['ABC'],'PR(>F)'] > 1:
    print('test positive')

1 Comment

this gives me the below error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.