BUG: rowLabels and colLabels args in pandas.plotting.table have no effect
[ yes ] I have checked that this issue has not already been reported.
[ yes ] I have confirmed this bug exists on the latest version of pandas.
[ yes ] (optional) I have confirmed this bug exists on the master branch of pandas.
# Your code here
import pandas as pd
from matplotlib import pyplot as plt
df = pd.DataFrame({'old_title':[42,73]})
fig,ax = plt.subplots(1,1)
pd.plotting.table(ax,df, colLabels=['new_title'], loc='center')
ax.axis('off')
plt.show()Problem description
Setting rowLabels or colLabels in pandas.plotting.table has no effect. I've found that the problem is in table() function of pandas/plotting/_misc.py as it returns plot_backend.table with predefined rowLabels=None, colLabels=None:
return plot_backend.table(
ax=ax, data=data, rowLabels=None, colLabels=None, **kwargs
)It obviously should just pass rowLabels and colLabels as is, instead.
Just replace rowLabels=None, colLabels=None with rowLabels=rowLabels, colLabels=colLabels in line 26 of _misc.py, please.
Expected Output
Expected output is a table with column named 'new_title' instead of 'old_title'
Output of pd.show_versions()
INSTALLED VERSIONS
commit : 67a3d4241ab84419856b84fc3ebc9abcbe66c6b3 python : 3.7.9.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19041 machine : AMD64 processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel byteorder : little LC_ALL : None LANG : en LOCALE : None.None
pandas : 1.1.4 numpy : 1.19.4 pytz : 2020.4 dateutil : 2.8.1 pip : 20.2.4 setuptools : 49.6.0.post20201009 Cython : 0.29.21 pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 2.11.2 IPython : 7.19.0 pandas_datareader: None bs4 : None bottleneck : None fsspec : None fastparquet : None gcsfs : None matplotlib : 3.3.2 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pytables : None pyxlsb : None s3fs : None scipy : 1.5.3 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None numba : None
Source: pandas-dev/pandas