Last active
April 4, 2018 07:59
-
-
Save kurozumi/f430a36aaedb81153b45be4293951b01 to your computer and use it in GitHub Desktop.
【Python】Pandasを使ってCSVをjsonに変換する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import pandas as pd | |
df = pd.read_csv("sample.csv") | |
# ヘッダーがある場合 | |
json = df.to_json(orient="records") | |
print(json) | |
# ヘッダーがない場合 | |
json = df.to_json(orient="values") | |
print(json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment