python - Plot table and display Pandas Dataframe -
i want display pandas dataframe on screen in tabular format:
df = pd.dataframe({'apples': 10, 'bananas': 15, 'pears': 5}, [0])
i'm not sure how so. know pd.dataframe.plot() has options display table, along graph. want display table (i.e. dataframe) on screen. thanks!
edit:
here's screenshot of creating table using pandas plot function. want bottom table portion however, not graph. want popup of table figure.
edit 2:
i managed display dataframe on figure following:
plt.figure() y = [0] plt.table(celltext=[10, 15, 5], rowlabels=[0], columnlabels=['apple', 'bananas', 'pears'], loc='center') plt.axis('off') plt.plot(y) plt.show()
this display table without of axes. don't know if best way go it, suggestions appreciated. also, there way add title table? way know use plt.text , place text (title of table) within figure, have keep axes...any ideas?
line 2-4 hide graph above,but somehow graph still preserve space figure
import matplotlib.pyplot plt ax = plt.subplot(111, frame_on=false) ax.xaxis.set_visible(false) ax.yaxis.set_visible(false) the_table = plt.table(celltext=table_vals, colwidths = [0.5]*len(col_labels), rowlabels=row_labels, collabels=col_labels, cellloc = 'center', rowloc = 'center') plt.show()
Comments
Post a Comment