Question:
I tried to create some numbers and rename the output columns with thenp.arange
loop as the following:The columns’ names were fine between columns
reject0.6-reject0.68
.
After that, all columns’ names turned to reject
with the unexpected numbers, e.g., reject0.6900000000000001
, reject0.8000000000000002
, reject0.9900000000000003
for all other columns as the attached the picture shows.[column names]

I am curious why the numbers are different after 0.69. I tried to simply replace
np.arange
with np.linspace
, but it doesn’t work for me.
Am I wrong with any part?I appreciate any help you can provide.
Answer:
You are seeing the tail of the floating point precision. It is impossible to exactly represent most floats, and we end up with a tail that end at the numeric precision.I think you can solve this by formatting the strings you are using for column names.
If you have better answer, please add a comment about this, thank you!