'Error trying to mathematically manipulate Pandas DataFrame
I have been trying to carry out some mathematical operations the DataFrame as follows:
Here is the data frame:
DfD =
D1 D2 D3 D4 D5 D6 D7 D8 D9 I ... P3 P4 P5 P6 P7 P8 P9 R S time
0 [0.0, 4.495308187547649e-06, 3.560980908381618... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
... [10.0, 9.956694041903512, 9.913575624407693, 9... ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ...
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... [0.0, 0.08510849164745524,
0.1669133041179413,... [60.0, 59.99999725256998, 59.99997823553143, 5... [0.0, 0.1, 0.2,
0.30000000000000004, 0.4, 0.5,...
###Here is the code:
import pandas as pd
import numpy as np
### Defining constant parameters:
T=(100+273.15); # Operating temperature in degrees Kelvin,K.
R= 8.3145; #J.mol^-1.K^-1.
### Pre-defining the kinetic parameters we have:
f= 0.85;#2*89.91*math.exp(-14240/(T*R));
k_d = 4.340*10**(-2);
k_p = 2.170*10**(7)*math.exp(-3.243*10**(7)/(T*R));
k_t = 8.2*10**(9)*math.exp(-1.145*10**(7)/(T*R));
### Mathematically Manipulating the DataFrame
np.seterr(invalid='ignore')
dfD = pd.DataFrame(d_result)
dfD = dfD.astype(float)
vpD=np.multiply(np.sqrt(np.true_divide((f*k_d*dfD['M']),k_t)),k_p*dfD['M'])
vpD
I got the Error message:
ValueError: Setting an array element with a sequence.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
