There’s no problem using floats as dict keys.
Just round(n, 1)
them to normalise them to your keyspace. eg.
>>> hash(round(6.84, 1))
3543446220
>>> hash(round(6.75, 1))
3543446220
More Related Contents:
- Return a default value if a dictionary key is not available
- Dictionary: Get list of values for list of keys
- How to get a random value from dictionary?
- How to add multiple values to a dictionary key in python?
- How to add multiple values to a dictionary key?
- Merging two CSV files using Python
- How to print a dictionary’s key?
- switching keys and values in a dictionary in python [duplicate]
- Accessing dict_keys element by index in Python3
- How can I get a random key-value pair from a dictionary?
- How can I get dictionary key as variable directly in Python (not by searching from value)?
- Why must dictionary keys be immutable?
- I am trying to modify a dictionary value using the exec function
- How to copy a dictionary and only edit the copy
- How to suppress scientific notation when printing float values?
- Replace values in a pandas series via dictionary efficiently
- Convert floating point number to a certain precision, and then copy to string
- Merging dictionary value lists in python
- Floating Point Limitations [duplicate]
- How to create a dictionary of two pandas DataFrame columns
- numpy float: 10x slower than builtin in arithmetic operations?
- Is self.__dict__.update(**kwargs) good or poor style?
- How can I avoid “RuntimeError: dictionary changed size during iteration” error?
- dataframe to dict such that one column is the key and the other is the value [duplicate]
- Python dictionary comprehension using locals() gives KeyError
- Round a floating-point number down to the nearest integer?
- Using Python class as a data container [closed]
- How can I convert string values from a dictionary, into int/float datatypes?
- sorting list of nested dictionaries in python
- In what case would I use a tuple as a dictionary key? [closed]