Spaces:
Sleeping
Sleeping
Update pages/6_Semi_structured_data.py
Browse files
pages/6_Semi_structured_data.py
CHANGED
|
@@ -395,6 +395,7 @@ elif file_type == "JSON":
|
|
| 395 |
''')
|
| 396 |
|
| 397 |
st.header("Converting DataFrame into JSON...")
|
|
|
|
| 398 |
st.code('''import pandas as pd
|
| 399 |
a = {"name":"harii","age":23,"marks":{"sem1":{"hindi":10,"science":39},"sem2":{"hindi":12,"science":32}}}
|
| 400 |
pd.json_normalize(a)
|
|
@@ -404,6 +405,16 @@ elif file_type == "JSON":
|
|
| 404 |
- **max_level** gives how much deeper it takes to take the values of column
|
| 405 |
''')
|
| 406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
|
| 408 |
|
| 409 |
|
|
|
|
| 395 |
''')
|
| 396 |
|
| 397 |
st.header("Converting DataFrame into JSON...")
|
| 398 |
+
st.subheader("Using max_level... ")
|
| 399 |
st.code('''import pandas as pd
|
| 400 |
a = {"name":"harii","age":23,"marks":{"sem1":{"hindi":10,"science":39},"sem2":{"hindi":12,"science":32}}}
|
| 401 |
pd.json_normalize(a)
|
|
|
|
| 405 |
- **max_level** gives how much deeper it takes to take the values of column
|
| 406 |
''')
|
| 407 |
|
| 408 |
+
st.subheader("Using record_path and meta...")
|
| 409 |
+
st.code('''import pandas as pd
|
| 410 |
+
x=[{"name":"p1","age":22,"marks":[{"maths":11,"hindi":41}]},{"name":"p1","age":21,"marks":[{"maths":22,"hindi":31}]}]
|
| 411 |
+
pd.json_normalize(x,record_path="marks",meta=["name","age"])
|
| 412 |
+
''')
|
| 413 |
+
st.markdown('''
|
| 414 |
+
- **record_path** only used when values are in list of dictionary
|
| 415 |
+
- **meta** is used to get remaining columns
|
| 416 |
+
''')
|
| 417 |
+
|
| 418 |
|
| 419 |
|
| 420 |
|