I dont understand why the headers of my table are repeated on every row rather than just the first row as expected.
Also why my print("Closest Approach", min(table))
is also repeated onto every row rather than just singularly printing the minimum value of the distances within the table on separate output. Could someone advise on where I have went wrong or how it can be fixed?
Thanks in advance.
I have tried the headers="firstrow"
and headers="keys"
functions but to no avail.
My link for the code is here,if you can identify problem from output.
Here is the Google Colab code for reference;
def update(i):
exdata.append(xelist[i])
eydata.append(yelist[i])
jxdata.append(xjlist[i])
jydata.append(yjlist[i])
line_e.set_data(exdata,eydata)
point_e.set_data(xelist[i],yelist[i])
text_e.set_position((xelist[i],yelist[i]))
line_j.set_data(jxdata,jydata)
point_j.set_data(xjlist[i],yjlist[i])
text_j.set_position((xjlist[i],yjlist[i]))
point_s.set_data(xslist[i],yslist[i])
text_s.set_position((xslist[i],yslist[i]))
ax.set_xlim(-5.8*AU,5.8*AU)
ax.set_ylim(-5.8*AU,5.8*AU)
dist = sqrt((exdata[-1] - jxdata[-1])**2 + (eydata[-1] - jydata[-1])**2)
annotation.set_data(x=exdata[-1], y=eydata[-1], dx=jxdata[-1] - exdata[-1], dy=jydata[-1] - eydata[-1])
text_a.set_position(((exdata[-1] + jxdata[-1]) / 2, (eydata[-1] + jydata[-1]) / 2))
text_a.set_text(f"{dist/1e9:.1f} km(Mill) ")
table = [[(i),(f"{dist/1e9:.1f}")]]
print("Closest Approach", min(f"{dist/1e9:.1f}"))
print(tabulate(table, headers=["Time since last Closest Approach (Days)","Distance Between Planets (km*Mill) "]))