I am new to Python and I am trying to replicate functionality that I am quite used to in SAS. I want to create a new variable (data column) that contains the result of a computation using existing variables (data column) for that same row (record). And I want this new variable to be part of the existing dataset. After much research, I can't find anything on this specific topic. The dataset originates from a CSV file that contains two columns of numerical data, and the row size is not knowable a priori. I can perform the calculations I need without any issues, but trying to expand the dataset to have a third column in which I can place the results is where I'm getting stuck.
import numpy as np
import pandas as pd
driver1_1_data = pd.read_csv(...)
for i in range(len(driver1_1_data.values[:,0])):
MPS = np.sqrt((driver1_1_data.values[i,0]-driver1_1_data.values[i-1,0])**2+(driver1_1_data.values[i,1]-driver1_1_data.values[i-1,1])**2)