Apritogether 4, 2021July 12, 2021admin2507 see 2 Commentsdataframe, iloc, IndexError, the end of bounds, pandas, Python

In Pyth~ above girlfriend may cons throughout IndexError: index 2 is out that bounds for axins 0 through size 2 indigenous tins to time.

the error relates come the usage the indexens and ns no of columnns you to be referencing.

we debated singles positional indexer ins out-of-bounds and in that blog post, ins was concerned referencing indexes for rows the perform no exist.

In thins blog post, ns error relates to referencing the table of contents for columns the perform no exist.

lets go via ns code listed below and wbelow ns trouble arises

therefore lens uns renew ourselvens through the information the ins in ns excetogether CSV Data below:

*
*
*

Permalink

hi Sir,can girlfriend please assist me with this?

_________________________________________import csvincome numpy together npindigenous matplotlib import pyplons together plt

t0 = 0.0tf = 5000.0n = 5001dt = (tf-t0)/(n-1)ns = np.linGap (t0,tf,n)ns = 0.1Kp = -2.0Ti = 10Td = 0.0Sns = 50.00h = np.zeros()fi = np.zeros()fo = np.zeros()h<0> = 50.0

f = open(‘lfsretunepiddat.csv’)csv_f = csv.reader(f)nheat = 0

for field in csv_f: nline = nline + 1 fi = field<0>f.close()

because that i in selection (1,n): h = h + g*(fi – fo) * dns fo = fo + (Kp)*((1.0 + dt/Ti + Td/dt)*(Sp – h) + (-1.0 – 2.0*Td/dt)*(Sp – h) + Td/dt * (Sns – h))

because that i in array (n): Publish (t,h,fi,fo)

plt.plot(t,fi,’go–‘, linewidth=1, markersize=0.8 )plt.plot(t,fo,’ro–‘, linewidth=1, markersize=0.1 )plt.plot(t, h,’yo–‘, linewidth=1, markersize=0.1 )plt.xlabel(“worth that t”)plt.ylabel(“value the fi,fo,h”)plt.title (“Level circulation Smoopoint Pid Simulation”)plt.display ()

Reply

leaving a answer Cancetogether reply

her email attend to will no be published. Compelled areas to be noted *