So i'm not using python on my day to day basis so this is kind of new to me, but I have large amount of csv files to edit and I imagine a simple script can save me a lot of time.
suppose I have a table input data
I want to create a new table that perform the following operation on each set y[i] (a column in the table)
z[i] = (y[i]-y[0])/(y[5]-y[0]) - i
So far I have some issue including the index i (the row index) in the arithmetic operation
What I've managed so far: `
import pandas as pd
#import data file
csv_in = pd.read_csv('data.csv')
#creating the denominator
lsb = csv_in.iloc[5] - csv_in.iloc[0]
#here i'm missing -i in the end
inl = (csv_in.iloc[0] + csv_in)/lsb - csv_in.index.to_series()
print(inl)
So i'm wondering if there is a way to do it with a one liner like this? the
csv_temp.index.to_series()
didn't work, I assume i'm messing with the dimensions of the arrays i'm trying to operate on. do I have to do some kind of a loop?
the result should be output data
Thanks!