Nested for loop in graph

Hello, I need to be able to plot data from a structure with multiple nested iterables, making the xaxis to take the values from one of them and the yaxis another one nested in the previous one. I have created a more simple example to illustrate it, the error being in the way I place the for loop:
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go

datast = {
    'items': {
        '01': {
            'time': 2,
            'serial_no': 'unit_1',
            'data': {
                'expedition': 'Antarctic',
                'devices':{
                    'battery': {
                        'life': 100,
                        'error': 5
                    },
                    'engine': {
                        'life': 200,
                        'error': 8
                    },
                    'rudder': {
                        'life': 50,
                        'error': 15
                    }
                }
            }
        },
        '02': {
            'time': 5,
            'serial_no': 'unit_7',
            'data': {
                'expedition': 'Pacific',
                'devices': {
                    'battery': {
                        'life': 150,
                        'error': 3
                    },
                    'engine': {
                        'life': 250,
                        'error': 7
                    },
                    'rudder':{
                        'life': 90,
                        'error': 12
                    }
                }
            }
        }
    },
    'author': 'blue',
    'amount': 1500
}

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']


app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
    dcc.Graph(
            id='errors-plot',
            figure={
                'data': [go.Scatter(
                    x=datast[datast['items'][j]['data']['devices'] == i]['items'][j]['time'],
                    y=datast[datast['items'][j]['data']['devices'] == i]['items'][j]['data']['devices'][i]['error'],
                    mode='markers',
                    name='errors',
                    text=i
                    ) for j,i in datast['items'], datast[j]['data']['devices']
                    ],
                'layout': go.Layout(
                    title='Devices Software Messages',
                    xaxis={'title': 'Time'},
                    yaxis={'title': 'Number of messages'},
                    margin={'l': 100, 'b': 40, 't': 10, 'r': 50},
                    legend={'x': 0, 'y': 1},
                    hovermode='closest')
            }
    )
])

if __name__ == '__main__':
    app.run_server()