Working in Python 3.8.5
Problem: CSV file containing 100 rows, two columns containing data that are needed for a module to perform a calculation. I would like to run each row with the two data points, take the output and insert it into a third column.
Action so far: I found the module CSV and can use CSV.reader to read each line. I can see how I would get the output of the data points but not how to take them and use them in the module I need to run to process the data. I also found subprocess which I believe is the module which will let me process each line. I'm just finding it difficult to connect both of these.
Example data:
DateTime,Date,Time,Wind_Direction,Effective_Fetch,Wind_Speed
01/10/2012 00:00,01/10/2012,00:00:00,228,510,1.976
01/10/2012 00:10,01/10/2012,00:10:00,231,516,1.389
01/10/2012 00:20,01/10/2012,00:20:00,239,532,1.759
The two columns I want to process are Effective_Fetch and Wind_Speed.
The module is as follows:
def Hs(w, Lf):
gravity=9.81 #ms^-2
slope=0.0026
x = (slope)*(gravity**(-0.53))*(w**(1.06)*(Lf**(0.47)))
return x
w is Wind_Speed, Lf is Effective_Fetch and x is the value that I would like to insert into a column following Wind_Speed with the column header "Wave_Height" - I've read other modules that should be able to do this too in Pandas.