Hello! I am a relatively new python user with little experience in for loops, and one is definitely necessary for my project. I have a pandas dataframe that looks like this:

And I need to “integrate” the accel columns their respective velocity (and eventually position) and the angular into degrees. However, since the first row needs to be all 0s, there has to be two conditions inside the for loop: first row, and then everything else. The code I have so far looks like this:

Thanks for correcting the math! The new variables should simply be assigned into a new list or dataframe, which is what I was hoping the x_angle[i] would do, but it appears that that is not the correct way to do it. Basically, I am looking for a way to keep the original values and more or less create a new dataframe (or list, but that is easily convertible) that corresponds row-by-row to the original. The new dataframe would look nearly identical to the first, only that the values are changed (ideally correctly) and the columns would be x_velocity and x_angle instead of x_accel and x_angular.

Please take a look at my updated response. Even if we change the + to *, it still won’t give you radians as the final result. Please check that you are setting up the expression correctly.

Can you state the units of each variable (term) in the expression?

Sure! The accel columns are in terms of m/s^2, and the angular columns are in terms of deg/sec. The time column is in seconds (I have updated the values because it is supposed to be at 1.6… seconds, not 16).

Ok, thank you. If that is true, and we substitute only the units, we have on the right side of the expression:

= `m/s^2 + deg/s * s` # The `s` cancel out
= `m/s^2 + deg`

You see, this does not give you degrees on the left side of the expression. You first have to make sure that you are setting up your expressions correctly and that the correct units are being used.

Thanks for pointing that out, I will get to fixing that asap. As far as the declaration goes, is x_angle[i] correct for creating a new variable each time the loop iterates?

for i in range(10):
x_angle.append(i) # Here, I am just filling it in with index values
print('x_angle = :', x_angle)

In your case, you can include the expression inside the parenthesis, as in (here is a general example):

x_angle = []
c = 2
h = 4.5
for i in range(10):
x_angle.append(i**c - h) # Here, I am just filling it in with misc expression
print(x_angle)

if not, then just use a temp variable as an intermediary, then include it inside the parenthesis to append the value into the list. Experiment so that you become familiar with Python.