python comparing elements in dictionary to a float

Allie H

If I have a dictionary of pvalues, such that accessing pvalues[i][classes[j]] gives the pvalue from comparing class j to other classes in row i. However, when I try to iterate over the dictionary to find the significant values (i.e., if pvalues[i][classes[j]] < 0.05), I get TypeError: unorderable types: list() < float(). Is there anyway to compare the list elements to the 0.05 float without flattening the list and losing the class designations? Thanks.

Shasha99

As you mentioned in your comment, Your pvalues[i][classes[j]] is actually giving a list which is then being compare to float. You should compare the first element of that list and the float instead :

if pvalues[i][classes[j]][0] < .5 :
    print("it worked!!!")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Comparing all the elements in a dictionary

From Dev

comparing python dictionary values

From Dev

Python: Comparing dictionary key with string

From Dev

Comparing lists by comparing values of elements of the list in Python

From Dev

Comparing elements of one dictionary to ranges of values in another dictionary

From Dev

Comparing elements of one dictionary to ranges of values in another dictionary

From Dev

comparing list of tuple elements python

From Dev

comparing list of tuple elements python

From Dev

Adding Elements to a Dictionary in Python

From Dev

Comparing Python Decimals created from float and string

From Dev

Comparing Python list values to dictionary keys

From Dev

Python : comparing lines of a file with keys of a dictionary in the memory

From Dev

Comparing occurrences of a string in a list of lists to a dictionary in python

From Dev

Comparing values in one dictionary with values from another dictionary in Python

From Dev

Python, sets, Comparing two elements in the same set

From Dev

Comparing two lists in python if elements exist

From Dev

Comparing tuple elements against integers with Python

From Dev

Comparing all elements of 2 lists with Python 2

From Dev

python accessing elements in a dictionary inside dictionary

From Dev

Dictionary is not giving all elements - Python

From Dev

Finding if there are distinct elements in a python dictionary

From Dev

python how to compare elements in a dictionary?

From Dev

(Python) Filling a dictionary with specific elements

From Dev

Python - compare list elements with dictionary elements

From Dev

How to convert unicode to integer or float in dictionary in Python

From Dev

How to convert unicode to integer or float in dictionary in Python

From Dev

Read Float from MySQL into dictionary with Python

From Dev

Python: How to multply a dictionary of lists for a dictionary of float numbers?

From Dev

Choice made by Python 3.5 to choose the keys when comparing them in a dictionary

Related Related

  1. 1

    Comparing all the elements in a dictionary

  2. 2

    comparing python dictionary values

  3. 3

    Python: Comparing dictionary key with string

  4. 4

    Comparing lists by comparing values of elements of the list in Python

  5. 5

    Comparing elements of one dictionary to ranges of values in another dictionary

  6. 6

    Comparing elements of one dictionary to ranges of values in another dictionary

  7. 7

    comparing list of tuple elements python

  8. 8

    comparing list of tuple elements python

  9. 9

    Adding Elements to a Dictionary in Python

  10. 10

    Comparing Python Decimals created from float and string

  11. 11

    Comparing Python list values to dictionary keys

  12. 12

    Python : comparing lines of a file with keys of a dictionary in the memory

  13. 13

    Comparing occurrences of a string in a list of lists to a dictionary in python

  14. 14

    Comparing values in one dictionary with values from another dictionary in Python

  15. 15

    Python, sets, Comparing two elements in the same set

  16. 16

    Comparing two lists in python if elements exist

  17. 17

    Comparing tuple elements against integers with Python

  18. 18

    Comparing all elements of 2 lists with Python 2

  19. 19

    python accessing elements in a dictionary inside dictionary

  20. 20

    Dictionary is not giving all elements - Python

  21. 21

    Finding if there are distinct elements in a python dictionary

  22. 22

    python how to compare elements in a dictionary?

  23. 23

    (Python) Filling a dictionary with specific elements

  24. 24

    Python - compare list elements with dictionary elements

  25. 25

    How to convert unicode to integer or float in dictionary in Python

  26. 26

    How to convert unicode to integer or float in dictionary in Python

  27. 27

    Read Float from MySQL into dictionary with Python

  28. 28

    Python: How to multply a dictionary of lists for a dictionary of float numbers?

  29. 29

    Choice made by Python 3.5 to choose the keys when comparing them in a dictionary

HotTag

Archive