Python Code

json 파일을 읽고 DataFrame으로 바꾸는 코드

Kimhj 2023. 11. 21. 17:55
import pandas as pd
import json

def json_to_dataframe(json_file_path):
    with open(json_file_path, 'r') as json_file:
        data = json.load(json_file)

    # 데이터프레임으로 변환
    dataframe = pd.DataFrame(data)

    return dataframe

# 사용 예시
json_file_path = 'path/to/your/file.json'
df = json_to_dataframe(json_file_path)

# 데이터프레임 확인
print(df)