I've extracted the data into a JSON file (it is a nest filed)
I've read_json to extract the data into a pandas:
df = pd.read_json('./data0000.json')
but got this as the data is nested ( all the fields are under Data):
Data
0 {field 1, field 2, field 3....)
How do I unnest it in a panda dataframe?
For the following data format, read_json() works as you would like:
[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
We would still need to see your data for a full fix, but you may also want to explore the "orient" parameter in read_json().
data = pd.read_json('data0000.json',orient='records')
Allowed values for orient are: {'split','records','index','columns','values'}
From the docs link :
DataFrame
'columns'
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.