[Python] DataFrame

순서 섞기

df_shuffled=df.sample(frac=1).reset_index(drop=True)

# DataFrame to JSON
df.to_json(orient = 'records')

# 옵션
orient = 'columns'
orient = 'records'
orient = 'index'
orient = 'split'
orient = 'table'

# Json Normalize

import pandas as pd
import json
from pandas import json_normalize

data = '''
{
"Results":
         [
         { "id": "1", "Name": "Jay" },
         { "id": "2", "Name": "Mark" },
         { "id": "3", "Name": "Jack" }
         ],
"status": ["ok"]
}
    '''

info = json.loads(data)

df = json_normalize(info['Results']) #Results contain the required data
print(df)

Subscribe to Keun's newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!