Thoughts, stories and ideas.

[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)