【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