Spaces:
Sleeping
Sleeping
Update pages/6_Semi_structured_data.py
Browse files
pages/6_Semi_structured_data.py
CHANGED
|
@@ -340,6 +340,42 @@ elif file_type == "JSON":
|
|
| 340 |
output = '{"name":{"0":"harii","1":"sree","2":"gowtham"},"age":{"0":21,"1":24,"2":25},"weight":{"0":34,"1":45,"2":67}}'
|
| 341 |
''')
|
| 342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
|
| 344 |
|
| 345 |
|
|
|
|
| 340 |
output = '{"name":{"0":"harii","1":"sree","2":"gowtham"},"age":{"0":21,"1":24,"2":25},"weight":{"0":34,"1":45,"2":67}}'
|
| 341 |
''')
|
| 342 |
|
| 343 |
+
st.subheader("Orient as Values...")
|
| 344 |
+
st.markdown('''
|
| 345 |
+
- In orient as values while converting DataFrame into json it gives you list of list (nested list)
|
| 346 |
+
''')
|
| 347 |
+
st.code('''import pandas as pd
|
| 348 |
+
a = '{"name":["harii","sree","gowtham"],"age":[21,24,25],"weight":[34,45,67]}'
|
| 349 |
+
data = pd.read_json(a)
|
| 350 |
+
val = data.to_json(orient="values")
|
| 351 |
+
val
|
| 352 |
+
''')
|
| 353 |
+
st.markdown('''
|
| 354 |
+
- Output will be:
|
| 355 |
+
''')
|
| 356 |
+
st.code('''
|
| 357 |
+
output = '[["harii",21,34],["sree",24,45],["gowtham",25,67]]'
|
| 358 |
+
''')
|
| 359 |
+
|
| 360 |
+
st.subheader("Orient as Split...")
|
| 361 |
+
st.markdown('''
|
| 362 |
+
- In orient as split while converting DataFrame into json it gives column names , indices and data seperately
|
| 363 |
+
- It is a dictionary of list
|
| 364 |
+
''')
|
| 365 |
+
st.code('''import pandas as pd'
|
| 366 |
+
a = '{"name":["harii","sree","gowtham"],"age":[21,24,25],"weight":[34,45,67]}'
|
| 367 |
+
data = pd.read_json(a)
|
| 368 |
+
spl = data.to_json(orient="split")
|
| 369 |
+
spl
|
| 370 |
+
''')
|
| 371 |
+
st.markdown('''
|
| 372 |
+
- Output will be:
|
| 373 |
+
''')
|
| 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 |
|
| 380 |
|
| 381 |
|