Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active April 4, 2018 07:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/f430a36aaedb81153b45be4293951b01 to your computer and use it in GitHub Desktop.
Save kurozumi/f430a36aaedb81153b45be4293951b01 to your computer and use it in GitHub Desktop.
【Python】Pandasを使ってCSVをjsonに変換する方法
# 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