Reputation: 37
#I have a dataframe for a growing polymerization reaction that looks like this:
d_result['M']=
array([70. , 69.99738611, 69.98974828, ..., 0.02669216,
0.02664559, 0.02659911])
d_result['time']=
array([ 0. , 0.1, 0.2, ..., 449.7, 449.8, 449.9])
#I intend to produce a plot of 'X' against 'time' for the growing chain versus time;
X = (d_result['M'][0]-d_result['M'][-1])/d_result['M'][0]. # 'X',Monomer conversion
d_trajectory = d_result
plt.plot(d_trajectory['time'], ((d_trajectory['M'][0]-d_trajectory['M'][:-1])/d_trajectory['M'][0]), 'k')
plt.xlabel('Time')
plt.ylabel('Conversion,X')
#I got the following error: #ValueError: x and y must have the same first dimension, but have shapes (4500,) and (4499,)
Upvotes: 0
Views: 199
Reputation: 101
d_trajectory['M'][:-1]
doesn't include the last element of the array and is therefore shorter by 1 than d_trajectory['time']
, see Understanding slice notation. Try d_trajectory['M']
or d_trajectory['M'][:]
.
Upvotes: 1