i have created this dataframe:
ones_df = pd.DataFrame(data=1, index= myscores.index, columns=['tracker'])
i have a loop that subtracts .05 from the values( starting at 1) until it reaches zero 0. then stop subtracting. BUT once it gets to .05 and tries to subtract .05 again. i get the value -3.191891e-16
IPdb [27]:
tracker_df.iloc[0]
tracker 0.05
Name: 4155.0, dtype: float64
IPdb [28]:
tracker_df.iloc[0] -.05
tracker -3.191891e-16
Name: 4155.0, dtype: float64
i am not sure how, if i start with data value 1 and continue to just subtract .05 this happens. when I use float() and it shows the "true value" which is less than then .05 i was expecting, so technically this will never get to 0 and be True
IPdb [29]: float(tracker_df.iloc[0])
0.049999999999999684
so my questions are, how can i fix this from the start (so i dont need to do a round(2) ) in order to get to my zero value, and also why does this happen. thanks