Search code examples
pythonpandasunique

why does unique() returns the same value?


Consider test dataframe which has a column named "quantile0.1_mrp". why does unique() returns 2 identical values?

enter image description here

edit: (as @jezrael commented, it is because of precision)

enter image description here


Solution

  • Problem is with precision of floats, pandas/numpy sometimes display truncated values.

    You can check it converting to lists.

    print (list(test['quantile0.1_mrp'].unique()))
    

    Possible solution is round values:

    print (test['quantile0.1_mrp'].round().unique())