I tried to use json normalize
in nested dictionary as showed in image A and it show error string indices must be integers
. Here is my code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from pandas.io.json import json_normalize
df=pd.read_csv('applied_work.csv')
df_=df.loc[:,['job_id', 'user_id', 'job_title', 'city','state']]
df_try=pd.json_normalize(data=df_try, record_path='job_title')
You may use DataFrame.from_dict
And pay attention in the orient Parameter:
orient{'columns', 'index'}, default 'columns'
The “orientation” of the data. If the keys of the passed dict should be the columns of the resulting DataFrame, pass 'columns' (default). Otherwise if the keys should be rows, pass 'index'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.