How to display multi level dataset

Hi,

If I have this dataset

orders = [{
    "num":160,
    "cust":"my cust",
    "lines":[
        {        
            "num":160,
            "item":"first item"        
        },
        {        
            "num":160,
            "item":"second item"        
        }
    ]
    
}]

How do you display it like

num   cust       item         qty
-----------------------------------------
160   my cust   first item    111
                second item   222

Thanks!

You could reshape your dataset into wide format, along the lines of:

import numpy as np
import pandas as pd
import streamlit as st

orders = {
    "num":[160, 161],
    "cust":["my cust", "new cust"],
    "item":[["first item","second item"], ["first item"]],
    "quantity":[[111, 222], [10]]
}

df = pd.DataFrame(orders)
st.write(df)

image

Thank you.

The dataset format is provided by an API, so don’t have much control over that.

So I guess, for now, after the call to the API, I’d have to reformat the dataset as you suggested.