본문 바로가기

언어 꿀Tip/Python 꿀tip!

07_01_47. json 파일 불러오기

두 개가 무슨 차이인지 모름! 

 

# 판매량 데이터
import json

# method 1
with open('./data/etc/sample/data.json') as json_file:
    json_data = json.load(json_file)
df = pd.DataFrame(json_data).drop(columns='index_col')

# method 2
with open('./data/etc/data.json') as json_file:
    json_data = json.load(json_file)
df = pd.DataFrame(list(json_data.values())[0])