import pandas as pd
df = pd.DataFrame({'id': [], 'first_name': [], 'last_name': []}).set_index('id')
print(df.to_markdown())
| id | first_name | last_name |
||
md5-c022a9062f651c0e45cc245637310d27
| id | first_name | last_name |
|-----:|-------------:|------------:|
| id | first_name | last_name |
||
| id | first_name | last_name |
|-----:|-------------:|------------:|
pd.show_versions()commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.4.0
Cython : 0.29.13
pytest : 5.2.1
hypothesis : None
sphinx : 2.2.0
blosc : None
feather : None
xlsxwriter : 1.2.1
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 3.0.0
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.2.1
pyxlsb : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.12
tables : 3.5.2
tabulate : 0.8.6
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.1
numba : 0.45.1
Thanks @ThibTrip
to_markdown is a wrapper around tabulate, and it looks like this issue was raised there: https://github.com/astanin/python-tabulate/issues/15
Looks like a fix was released too - perhaps just a case of specifying min tabulate version
@alimcmaster1 I've tried this with the latest release of tabulate on PyPI (0.8.6) and it's still present
I鈥檝e asked @astanin
@MarcoGorelli any chance this has resolved itself since Feb?
@MarcoGorelli any chance this has resolved itself since Feb?
Yes, that seems to be the case!
In [1]: import pandas as pd
...:
...: df = pd.DataFrame({'id': [], 'first_name': [], 'last_name': []}).set_ind
...: ex('id')
...: print(df.to_markdown())
| id | first_name | last_name |
|------|--------------|-------------|
I'll look into this to figure out when/how it was fixed
OK, there was a new release of tabulate in March (version 0.8.7) in which this was fixed
So, a short test (the snippet above is fine), and an update of the minimum required tabulate version in doc/source/getting_started/install.rst would be welcome here
take