How can I visualize correctly the table in Dash?

Viewed 175

I have a problem with a dash table. When I do a static table like adding elements manually it works, but when I do a dynamic table using functions or importing function I am not able to see anything. Jupyter doesn't give any error but the page is blank. Do you know why? so funny Some suggestions?

def Table1():
    try:
        TableQuote=yticker.Quote('AAPL')
        row1 = html.Tr([html.Td("Previous Close",style={'font-weight':'bold'}), html.Td(TableQuote[1])]),
        row2 = html.Tr([html.Td("Open",style={'font-weight':'bold'}), html.Td(TableQuote[2])]),
        row3 = html.Tr([html.Td("Day Range",style={'font-weight':'bold'}), html.Td(TableQuote[3])]),
        row4 = html.Tr([html.Td("52W Range",style={'font-weight':'bold'}), html.Td(TableQuote[4])]),
        row5 = html.Tr([html.Td("Volume",style={'font-weight':'bold'}), html.Td(TableQuote[5])]),
        row6 = html.Tr([html.Td("Beta",style={'font-weight':'bold'}), html.Td(TableQuote[6])]),
        table_body = [html.Tbody([row1, row2, row3, row4, row5, row6])],
        #table1 = dbc.Table(table_body, bordered=True),
        table1=dbc.Table(
           table_body,
           bordered=True,
           hover=True,
           responsive=True,
            striped=True,
         )
        return(table1)

    except:
        return ('na','na')


table1=Table1() 

  
GraphsTop=html.Div(style={'margin-left':'100px'},
                       children=[  
                       dbc.Row([
                           dbc.Col([
        html.Div(className='six columns',style={'width':'350px','height':'200px'},
                 children=[
                    html.H6('Ticker',className='subtitle padded',style={'height':'20px'}),
                     table1
                 ]),
                           ]),
                           dbc.Col(style={'padding-left':'150px'},
                                   children=[
        html.Div(className='six columns',style={'width':'350px','height':'200px'},
                children=[
                     html.H6('Fact Sheet2',className='subtitle padded',style={'height':'20px'}),
                     table1
                ]), 
                           ]),
                           ]),
])
    

    ###LAyout Finale
app.layout = html.Div([GraphsTop])

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

my function is this:

    import yahoo_fin.stock_info as si
    
def Quote(ticker):
        QuoteTable = si.get_quote_table(ticker)
        PEttm=QuoteTable["PE Ratio (TTM)"] # 22.71
        PreviousClose=QuoteTable["Previous Close"]
        Open=QuoteTable["Open"] 
        DayRange=QuoteTable["Day's Range"] 
        WRange=QuoteTable["52 Week Range"]
        Volume=QuoteTable["Volume"] 
        MarketCap=QuoteTable["Market Cap"] 
        Beta=QuoteTable["Beta (5Y Monthly)"] 
        EPSttm=QuoteTable["EPS (TTM)"]
        EarningDate=QuoteTable["Earnings Date"] 
        ExDivDate=QuoteTable["Ex-Dividend Date"] 
        QuotePrice=QuoteTable["Quote Price"] 
        return(PEttm,PreviousClose,Open,DayRange,WRange,Volume,MarketCap,Beta,EPSttm,EarningDate,ExDivDate,QuotePrice)
0 Answers
Related