Reputation: 43
I have two CSV tables.
I want to multipy the "Flaechenfaktor" from the first table with the whole timeseries from the second table.
So first I started with this:
data_area = pd.read_csv("U:\...\Flaechenfakt_Test.csv",sep=";",header=0)
data_timeseries = pd.read_csv("U:\...\Zeitreihe.csv",sep=";",header=0)
new_data= data_area.Flaechenfaktor[0]*data_timeseries.Coesfeld
This works well for the first timeseries from "Coesfeld". For the second one ("Recklinghausen") it would be easy to write it like I have done it with "Coesfeld". But instead of that way I want to iterate the rows in the first table and iterate the columns in the second table, because the table will grow with time. So my question is how can I iterate columns while iterating the rows?
Upvotes: 0
Views: 44
Reputation: 274
If I got the question correctly you can first define the columns you would like to iterate in a list column_to_iterate
and then
for number_of_column, column in enumerate(columns_to_iterate):
data_area.loc[number_of_column, 'Flaechenfaktor'] * data_timeseries[column]
number_of_column
will go from 0 to len(columns_to_iterate) - 1
, so you can browse the rows (if their index is the default integer sequence), while column
will browse the headers you selected
Upvotes: 1