I'm creating a dataframe in Pandas by reading it from a csv file. The dataframe contains several float values. When I iterrated through my dataframe using itertuples, one float value changed from 2.3 to 2.2999999999999998. First I thought this may occure because dataformats change from dataframe to tuple but the value is stored as float both in the dataframe and the tuple.
So my question is: Why does this happen?
print(dfAll)
speed=dfAll['speed']
for value in motion:
print(type(value))
for t in dfAll.itertuples():
print(type(t.speed))
print(t)
phase motion speed attention shape_speed shape_combination fail
0 1 80 1.7 90 up up 0
1 1 89 1.5 85 same same 0
2 1 75 2.3 75 down down 0
3 1 82 2.5 80 same same 0
4 1 30 0.0 0 0 0 1
<type 'numpy.float64'>
<type 'numpy.float64'>
<type 'numpy.float64'>
<type 'numpy.float64'>
<type 'numpy.float64'>
<type 'numpy.float64'>
Pandas(Index=0, phase=1, motion=80, speed=1.7, attention=90, shape_speed=u'up', shape_combination=u'up', fail=0)
<type 'numpy.float64'>
Pandas(Index=1, phase=1, motion=89, speed=1.5, attention=85, shape_speed=u'same', shape_combination=u'same', fail=0)
<type 'numpy.float64'>
Pandas(Index=2, phase=1, motion=75, speed=2.2999999999999998, attention=75, shape_speed=u'down', shape_combination=u'down', fail=0)
<type 'numpy.float64'>
Pandas(Index=3, phase=1, motion=82, speed=2.5, attention=80, shape_speed=u'same', shape_combination=u'same', fail=0)
<type 'numpy.float64'>
Pandas(Index=4, phase=1, motion=30, speed=0.0, attention=0, shape_speed=u'0', shape_combination=u'0', fail=1)