0

I have a question about a code. I would like to ask you something abput a code. I have a .csv file with no header 10 columns with numbers (float). I would like to make calculations between 1st and 9th column, using an equation. How could I firstly set/declare each column ?? For example I would like to set the first column as "X", the second as "X1" etc.

I have written only this until now

import pandas as pd
 
df = pd.read_csv('ALL.csv', usecols=[1,2,3,4,5,6,7,8,9,10,11], header=None)
print(df)

I am new in python and I need your help.

could you help me please?

Ivan Roma
  • 7
  • 1
  • 5
  • For example in Matlab I set as : importdata('ALL.csc'); X=data.(:,1). – Ivan Roma Aug 11 '20 at 05:39
  • df['eq']=df.apply(lambda row: row['col1']*row['col9'],axis=1) suppose your data header has col1 and col9 text at first row. Now we have new column with name eq which you can filter. Note: Times shows sample function, so you can replace it with what ever you want – paytam Aug 11 '20 at 06:40
  • Finally, the solution is: `import pandas as pd df = pd.read_csv('ALL.csv', usecols=[1,2,3,4,5,6,7,8,9,10,11], header=None) X=df[1]' etc – Ivan Roma Aug 11 '20 at 13:00

0 Answers0