pandas のversionは 1.0.0 以上が対応しています。
pd.__version__
'1.0.0'
事前にtabulateをインストールします。
pip install tabulate
テストデータ
data=[
{"氏名":"山田","回数":5, "国語":40 ,"算数":40 },
{"氏名":"山田","回数":4, "国語":40 ,"算数":50 },
]
サンプルソース
import pandas as pd
df=pd.DataFrame(data)
print(df.to_markdown())
結果
氏名 | 回数 | 国語 | 算数 | |
---|---|---|---|---|
0 | 山田 | 5 | 40 | 40 |
1 | 山田 | 4 | 40 | 50 |
[参考 What’s new in 1.0.0 (January 29, 2020)]
(https://pandas.pydata.org/docs/whatsnew/v1.0.0.html?highlight=to_markdown)