BUG: df.to_markdown() with empty frame incorrect output
See original GitHub issueCode Sample, a copy-pastable example if possible
import pandas as pd
df = pd.DataFrame({'id': [], 'first_name': [], 'last_name': []}).set_index('id')
print(df.to_markdown())
| id | first_name | last_name |
||
Problem description
The markdown output of empty DataFrames does not seem right to me (see Expected Output).
Expected Output
| id | first_name | last_name |
|-----:|-------------:|------------:|
Render difference
Current
| id | first_name | last_name | ||
Expected
id | first_name | last_name |
---|
Output of pd.show_versions()
INSTALLED 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Yes, that seems to be the case!
I’ll look into this to figure out when/how it was fixed
I’ve asked @astanin