title: "Expected an array. Was supplied type `object`." How to solve this error in my DataTable function for my Dash app?
body: <p>please look at my code and scroll to my <code>statsTable(symbols)</code> function, that is where my error comes up.</p>
  <pre><code>import dash
  import dash_table as dt
  import dash_bootstrap_components as dbc
  import dash_core_components as dcc
  import dash_html_components as html
  from dash.dependencies import Input, Output
  import plotly.express as px
  import plotly.graph_objs as go
  from dash.exceptions import PreventUpdate
  
  import pandas as pd
  
  from connect import *
  from dash_tables import *
  
  
  stock_ids = execute_query(conn, &quot;SELECT DISTINCT id FROM security_price;&quot;)
  stock_ids = [i[0] for i in stock_ids]
  options = [{'label': i, 'value': i} for i in stock_ids]
  
  app = dash.Dash(__name__, external_stylesheets=[dbc.themes.LUX],  meta_tags=[
          {&quot;name&quot;: &quot;viewport&quot;, &quot;content&quot;: &quot;width=device-width, initial-scale=1&quot;}])
  body = html.Div(
      [dbc.Jumbotron(
      [
          dbc.Container(
      [
          html.H1(&quot;SP500&quot;, className=&quot;display-4&quot;),
          html.P(
              &quot;Compare equities in the SP500 &quot;
              &quot;before you buy.&quot;,
              className=&quot;lead&quot;,
          ),
          html.P(
              &quot;Enter the symbols that interest you &quot;
              &quot;and view how they compare&quot;,
              
          ),
          
      ], 
          fluid=True,
          )
  
      ], 
      fluid=True,
  )
      , dbc.Row(dbc.Container(dcc.Dropdown(id=&quot;dynamic-dropdown&quot;, options=options, multi=True, placeholder=&quot;Select a Symbol&quot;, style={'margin-left': '20px', 'margin-right':'45px'}),fluid=True))
  
      , dbc.Row(dbc.Col(html.Div(children = [dcc.Graph(id='output-graph', config={'displayModeBar': False}, animate=True)], style={'padding': 10})))
  
          
      
      , dbc.Row([
             (html.Div(dbc.Container(dt.DataTable(id='table_stats', style_table={'margin-left': '20px', 'margin-right':'45px'}))))], justify=&quot;center&quot;)
  
              # lg=9, md=6, xs=4, style={'margin-left': '5px','padding': 10})
               #dbc.Col(html.Div(dbc.Alert(&quot;One of three columns&quot;, color=&quot;primary&quot;)), lg=3, md=4, xs=12, style={'padding' : 10})
              # # , dbc.Col(html.Div(dbc.Alert(&quot;One of three columns&quot;, color=&quot;primary&quot;)), lg=3, md=4, xs=12,style={'margin-right': '5px','padding': 10})
              # ], justify=&quot;center&quot;)
  
      , dbc.Row(dbc.Col(html.Div(dbc.Alert(&quot;This is one column&quot;, color=&quot;primary&quot;, style={'margin-top' : '25px' ,'margin-bot' : '25px'}))),style={'margin-left' : '25px' ,'margin-right' : '25px'}, justify=&quot;center&quot;)
          ])
  
  
  
  
  
  
  app.layout = html.Div([body])
  
  
  
  
  @app.callback(
  dash.dependencies.Output('table_stats', 'data'),
  [dash.dependencies.Input('dynamic-dropdown', 'value')])
  
  
  
  def statsTable(symbols):
      print(symbols)
      if symbols == None:
          raise PreventUpdate
      
      placeholders = &quot;, &quot;.join(['%s' for _ in symbols])
  
      # PREPARED STATEMENT WITH PARAM PLACEHOLDERS
      sql = f&quot;&quot;&quot;SELECT id, companyname, marketcap
                       , to_char(100.0*week52change,'999D99%%'), week52high, week52low
                       , to_char(dividend_yield * 100, '99D99%%'), next_earnings_date
                       , pe_ratio, ROUND(beta,2) 
                FROM security_stats 
                WHERE security_stats.id IN ({placeholders})
             &quot;&quot;&quot;
  
      print(sql)
  
      df = postgresql_to_dataframe_v1(conn, sql, symbols, stats_col)
      columns = df.columns
      data = df.to_dict('rows')
  
      
      table = dt.DataTable(data=data, columns=columns)
      print(table)
  
      return table
  
  
  
  
  if __name__ == &quot;__main__&quot;:
      app.run_server(debug = True)
  
  </code></pre>
  <p>This is <code>print(table)</code> to give you an example of what I'm passing:</p>
  <pre><code>DataTable(columns=Index(['Symbol', 'Company', 'Market Cap', '1yr-Change', '52-Week High',
         '52-Week Low', 'Dividend Yield', 'Next Earnings Report', 'PE-Ratio',
         'Beta'],
        dtype='object'), data=[{'Symbol': 'RSG', 'Company': 'Republic Services  Inc.', 'Market Cap': 31604176866, '1yr-Change': '  13.21%', '52-Week High': Decimal('102.58'), '52-Week Low': Decimal('65.78'), 'Dividend Yield': '  1.70%', 'Next Earnings Report': datetime.date(2020, 10, 25), 'PE-Ratio': Decimal('29.9'), 'Beta': Decimal('0.87')}])
  </code></pre>
  <p>This is <code>print(data)</code> to give you an example of what I'm passing:</p>
  <pre><code>[{'Symbol': 'RSG', 'Company': 'Republic Services  Inc.', 'Market Cap': 31604176866, '1yr-Change': '  13.21%', '52-Week High': Decimal('102.58'), '52-Week Low': Decimal('65.78'), 'Dividend Yield': '  1.70%', 'Next Earnings Report': datetime.date(2020, 10, 25), 'PE-Ratio': Decimal('29.9'), 'Beta': Decimal('0.87')}]
  </code></pre>
  <p>Below is the error that appears in the Dash Console:</p>
  <pre><code>Invalid argument `data` passed into DataTable with ID &quot;table_stats&quot;.
  Expected an array.
  Was supplied type `object`.
  </code></pre>
  <p>How can I fix this error?</p>