1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

dataframeからmarkdownの表を作るサンプルです。

Last updated at Posted at 2020-02-09

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)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?