Учитывая время и расстояние (2000 точек) от CSV, мне нужно рассчитать скорость и ускорение:
import math
import numpy as np
import pandas as pd
#Excercise 2a
#input the csv
df = pd.read_csv('Data_oscillator.csv')
time = df['Time'].values
distance = df['x(t)'].values
velob = np.zeros(2000)
accelb = np.zeros(2000)
# differentiating distance to find new velocity and acceleration
for i in range (0,1999):
velob[i] = (distance[i+1] - distance[i])/(time[i+1] - time [i])
for i in range (0,1999):
accelb[i] = (velob[i+1] - velob[i])/(time[i+1] - time[i])
Я получаю следующую ошибку:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-28-abd6ce780481> in <module>
5 # differentiating distance to find new velocity and acceleration
6 for i in range (0,1999):
----> 7 velob[i] = (distance[i+1] - distance[i])/(time[i+1] - time [i])
8
9 for i in range (0,1999):
TypeError: 'module' object is not subscriptable