Comments (2)
Hi phan480,
Use this piece of code: I think this should help u. Ping me if this is working.
import pandas as pd
data = [{
"id": 1039835,
"status": "on_track",
"development_plan": {
"id": 23858,
"items": [{
"id": 176498,
"item_name": "itemname 1"
}, {
"id": 172450,
"item_name": "itemname 2"
}, {
"id": 172451,
"item_name": "itemname 3"
}
]
},
"user": {
"id": 714067
}
}
]
Extract data
records = []
for entry in data:
status = entry['status']
user_id = entry['user']['id']
development_plan_id = entry['development_plan']['id']
for item in entry['development_plan']['items']:
record = {
'id': item['id'],
'item_name': item['item_name'],
'development_plan_id': development_plan_id,
'status': status,
'user_id': user_id
}
records.append(record)
Create DataFrame
df = pd.DataFrame(records)
print(df)
I got the following result:
id item_name development_plan_id status user_id
0 176498 itemname 1 23858 on_track 714067
1 172450 itemname 2 23858 on_track 714067
2 172451 itemname 3 23858 on_track 714067
from pandas.
Thank you for your response, yes it works. But doesn't use the json_normalize functionality? I am using this function to parse a multitude of api's and their responses. I configure their record_path and meta data columns in configuration data.
I would like to avoid creating a unique way to parse every API.
from pandas.
Related Issues (20)
- DOC: punctuation of titles in Titanic data HOT 1
- BUG: `unstack` with `sort=False` scrambles data HOT 3
- BUG: pandas.read_parquet fails to read parquet files with "file://" prefix on Windows HOT 2
- BUG: csv date inconsistencies HOT 2
- Potential performance regression with "BUG: DateTimeIndex.is_year_start unexpected behavior when constructed…" HOT 1
- BUG: output of pandas.util.hash_pandas_object() changed in pandas 2.2.x HOT 2
- BUG: docker build on windows fails; need eol=lf in .gitattributes HOT 2
- BUG: None value in MultiIndex can't be found HOT 1
- BUG: HDFStore doesn't save datetime64[s] right HOT 1
- ENH: Pivot Table HOT 1
- ENH: Pandas Tensor Data Type HOT 2
- BUG: Accessing a row with loc recasts dtype and can cause values to change depending on other columns HOT 2
- BUG: Reading large CSV files with `pyarrow` when values contain newline character. HOT 2
- DOC: Link to SPEC 0 instead of NEP 29 HOT 2
- BUG: `to_parquet(engine="fastparquet")` can't handle DataFrame with NumPy array values HOT 1
- ENH: new method `Series.struct.assign` to allow adding sub-fields to a struct
- BUG: sort_values with ascending=False is not doing stable sorting
- QST: This library always worked, except with this specific .sav file, anyone could give me a clue on why?
- Potential performance regression with "BUG: Fix issue with negative labels in `group_cumsum` (#58984)"
- BUG: can't support numpy2.2,how to deal with it HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandas.