I am trying to work with data from an accelerometer, trying to get the velocity from acceleration, on a df that looks like this:
{'T': {0: 0.007719999999999999,
1: 0.016677999999999797,
2: 0.024630999999996697,
3: 0.0325849999999983,
4: 0.040530999999995196},
'Ax': {0: 0.16, 1: 0.28, 2: 0.28, 3: 0.44, 4: 0.57},
'Ay': {0: 8.0, 1: 7.9, 2: 7.87, 3: 7.87, 4: 7.9},
'Az': {0: 3.83, 1: 3.83, 2: 3.79, 3: 3.76, 4: 3.76},
'delta T': {0: 0.00772,
1: 0.008957999999999798,
2: 0.0079529999999969,
3: 0.007954000000001606,
4: 0.007945999999996893}}
First, I set the Velocity of X, Y and Z to 0:
df_yt["Vx"] = 0
df_yt["Vy"] = 0
df_yt["Vz"] = 0
And then I entered the first value of each of these columns manually:
df_yt.loc[0,"Vx"] = 0.16*0.007720
df_yt.loc[0,"Vy"] = 8.00*0.007720
df_yt.loc[0,"Vz"] = 3.83*0.007720
I wanted to create a formula that returned the previous element in Vx + (Ax*delta T) of the same column. And to write the "formulas" of these 3 columns, I assumed it would be something like:
df_yt.loc[1:,"Vx"] = df_yt["Vx"].shift(1) + df_yt["Ax"]*df_yt["delta T"]
df_yt.loc[1:,"Vy"] = df_yt["Vy"].shift(1) + df_yt["Ay"]*df_yt["delta T"]
df_yt.loc[1:,"Vz"] = df_yt["Vz"].shift(1) + df_yt["Az"]*df_yt["delta T"]
and this code doesn't return any error but the numbers on the df don't match what they should, for example:
should be 0.005970:
0.003743 + 0.28*0.007953 = 0.005970
I hope someone can help me with this because I don't know what is causing this mistake and I can't even understand where the wrong numbers are coming from.