-1

Below is what I tried:

if (p_testing < 0.05):
    sig == True,
elif (p_testing > 0.05):
    sig == False

The output I am trying to have is either False or True. The error I am receiving is the following:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Thank you in advance for the help!

  • 1
    ```sig = True``` A single equal to sign for assignment. And without a comma ```,``` –  Jun 15 '21 at 03:55
  • What happened when you tried copying and pasting `the truth value of a Series is ambiguous` into a search engine? – Karl Knechtel Jun 15 '21 at 04:17

3 Answers3

1

Based on the code you have given.

if (p_testing < 0.05):
    sig == True,
elif (p_testing > 0.05):
    sig == False

I can tell that you want to assign a True or False to sig.

  • `==` is for comparing
  • `=` is for assigning

    And In your code, you are using a double equals to assign a value which is Cleary incorrect.

    So change it up.

    if (p_testing < 0.05):
        sig = True,
    elif (p_testing > 0.05):
        sig = False
    
  • Buddy Bob
    • 5,829
    • 1
    • 13
    • 44
    0

    Ok, First of all, == or double equal to sign is for comparison. It is used in if statements to check : is a equal to b? or a==b . And a single equal to sign = is an assignment operator. one_var=1 Here, 1 is assigned to one_var

    Here is the corrected code.

    if (p_testing < 0.05):
        sig = True
    elif (p_testing > 0.05):
        sig =False
    
    -1

    Got it, since p_testing was a series, i had to specify what value in the series, the solution was as follows:

    if (p_testing[0] < 0.05):
        sig = True
    elif (p_testing[0] > 0.05):
        sig = False