• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Unexpected number from using arange loop to name the columns

Resolved: Unexpected number from using arange loop to name the columns

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I tried to create some numbers and rename the output columns with the np.arange loop as the following:
The conditional number part worked for me.
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.9900000000000003for all other columns as the attached the picture shows.
[column names] 1
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!

python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How do I navigate a table without any easily accessible distinctions?

27/03/2023

Resolved: Can a pod make itself unavailable temporarily in kubernetes?

27/03/2023

Resolved: How to plot logistic probability for custom generalized additive model (GAM) plot?

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.