Harika22 commited on
Commit
3894596
Β·
verified Β·
1 Parent(s): 54a7467

Update pages/6_Semi_structured_data.py

Browse files
Files changed (1) hide show
  1. pages/6_Semi_structured_data.py +16 -4
pages/6_Semi_structured_data.py CHANGED
@@ -293,16 +293,28 @@ elif file_type == "JSON":
293
  - In structured JSON format, orient refers to the way data is organized or structured, particularly when converting between tabular data like DataFrames and JSON.
294
  - It determines the layout of the JSON representation.
295
  - Common orient types are
296
- β—† Index
297
- β—† Columns
298
- β—† Values
299
- β—† Split
300
  ''')
301
  st.subheader("How to read Structured JSON Format?...")
302
  st.code('''import pandas as pd
303
  a = '{"name":["harii","sree"],"age":[12,13]}'
304
  pd.read_json(a)
305
  ''')
 
 
 
 
 
 
 
 
 
 
 
 
306
 
307
 
308
 
 
293
  - In structured JSON format, orient refers to the way data is organized or structured, particularly when converting between tabular data like DataFrames and JSON.
294
  - It determines the layout of the JSON representation.
295
  - Common orient types are
296
+ - β—† Index
297
+ - β—† Columns
298
+ - β—† Values
299
+ - β—† Split
300
  ''')
301
  st.subheader("How to read Structured JSON Format?...")
302
  st.code('''import pandas as pd
303
  a = '{"name":["harii","sree"],"age":[12,13]}'
304
  pd.read_json(a)
305
  ''')
306
+ st.header("Converting DataFrame into JSON...")
307
+ st.subheader("Orient as Index...")
308
+ st.markdown('''
309
+ - In orient as index while converting DataFrame into json here keys are index and values are dictionary
310
+ - Inside dictionary keys are column names and values are values present in the data
311
+ ''')
312
+ st.code('''import pandas as pd
313
+ a = '{"name":["harii","sree","gowtham"],"age":[21,24,25],"weight":[34,45,67]}'
314
+ ind = data.to_json(orient="index")
315
+ ind
316
+ output = '{"0":{"name":"harii","age":21,"weight":34},"1":{"name":"sree","age":24,"weight":45},"2":{"name":"gowtham","age":25,"weight":67}}'
317
+ ''')
318
 
319
 
320