I joined two tables into one using pandas Concat function. I then put them in a pyplot table. I end up with a table where all the values have 1 decimal. The original tables did not have the decimal before concatenating.
How can I get a table without decimals?
I tried rounding the values in the tables before concatenating but this does not work.
This is my code:
frames = [country_tab, country_birth_tab]
result = pd.concat(frames, axis=1)
#print(result)
ax = plt.subplot(111, frame_on=False) # no visible frame
ax.xaxis.set_visible(False) # hide the x axis
ax.yaxis.set_visible(False) # hide the y axis
table2 = table(ax, result)
table2.auto_set_font_size(False)
table2.set_fontsize(16)
table2.scale(4,4)
For your case result = result.astype(int)
also should work. astype(int) is help to convert your float to int. So your columns will be integer.
Also that line can work your code.
result[["Column1", "Column2"]] = result[["Column1", "Column2"]].astype(int)
So your final code is :
frames = [country_tab, country_birth_tab]
result = pd.concat(frames, axis=1)
result = result.astype(int)
ax = plt.subplot(111, frame_on=False) # no visible frame
ax.xaxis.set_visible(False) # hide the x axis
ax.yaxis.set_visible(False) # hide the y axis
table2 = table(ax, result)
table2.auto_set_font_size(False)
table2.set_fontsize(16)
table2.scale(4,4)