Good afternoon, I am trying to multiply two columns of a dataframe (C)
. And add the results to a new column. I have tried different methods but none work. The most common error I encounter is:
TypeError: can't multiply sequence by non-int of type 'float'
The columns that a i want to multiply are: H04_PEDRO_MARIN
and SS(mg/l)
. And also i want to create a new column with the results.
C:
H04_PEDRO_MARIN SS(mg/l) multiplication
Fecha
26/07/11 14:00 0.000000 80.4 0.000000
26/07/11 15:00 0.000000 76.1 0.000000
26/07/11 16:00 0.000000 0 0.000000
26/07/11 17:00 0.000000 0 0.000000
26/07/11 18:00 0.000000 0 0.000000
... ... ... ...
12/04/12 10:00 9430.166667 61.18 9430.166667
12/04/12 11:00 9430.166667 60.05 9430.166667
12/04/12 12:00 9430.166667 59.43 9430.166667
12/04/12 14:00 9430.166667 56.98 9430.166667
[11568 rows x 3 columns]
I have tried:
C['multiplicaction'] = C['H04_PEDRO_MARIN'][1])*(C['SS(mg/l)'])
And
cols = ['H04_PEDRO_MARIN','SS(mg/l)']
C['multiplication'] = C[cols].prod(axis=1)
And don´t work
Even i have tried to separate both columns in different dataframes and multiply and don't work again.
Thanks for any solution.