Spaces:
Sleeping
Sleeping
Update pages/6_Semi_structured_data.py
Browse files
pages/6_Semi_structured_data.py
CHANGED
|
@@ -374,6 +374,26 @@ elif file_type == "JSON":
|
|
| 374 |
st.code('''
|
| 375 |
output = '{"columns":["name","age","weight"],"index":[0,1,2],"data":[["harii",21,34],["sree",24,45],["gowtham",25,67]]}'
|
| 376 |
''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
|
| 378 |
|
| 379 |
|
|
|
|
| 374 |
st.code('''
|
| 375 |
output = '{"columns":["name","age","weight"],"index":[0,1,2],"data":[["harii",21,34],["sree",24,45],["gowtham",25,67]]}'
|
| 376 |
''')
|
| 377 |
+
st.subheader("**Issues in Structured JSON Format**")
|
| 378 |
+
st.markdown('''
|
| 379 |
+
- As in structured json format it reads only string format when the data is in heterogenous like dictionry of dictionary and list of dictionary we can't use pd.json_normalize()
|
| 380 |
+
- To handle this issue we use semi-structured json format which can handle nested structures
|
| 381 |
+
''')
|
| 382 |
+
st.header("Semi-structured JSON Format")
|
| 383 |
+
st.markdown('''
|
| 384 |
+
- A semi-structured JSON format lacks a fixed schema, allowing irregular or nested structures
|
| 385 |
+
- It takes list of dictionaries where each dict will be acting as a single row
|
| 386 |
+
- Semi-structured json format has different types to convert dataframe into json
|
| 387 |
+
- ◆ max_level ---> how much deeper it takes to take the values of column
|
| 388 |
+
- ◆ record_path ---> only used when values are in list of dictionary
|
| 389 |
+
- ◆ meta ---> it is used to get remaining columns
|
| 390 |
+
''')
|
| 391 |
+
st.subheader("How to read Semi-structured JSON Format?...")
|
| 392 |
+
st.code('''import pandas as pd
|
| 393 |
+
b = {"name":"a","marks":{"sem1":{"maths":22,"science":23},"sem2":{"maths":24,"science":25}}}
|
| 394 |
+
pd.json_normalize(b)
|
| 395 |
+
''')
|
| 396 |
+
|
| 397 |
|
| 398 |
|
| 399 |
|