title: Dash Plotly error TypeError: Object of type DataFrame is not JSON serializable
body: <p>Hello I am working with Dash for making dashboard.
  Below is my code.
  I tried to fix the error but not able to fix, Can anyone look into this?
  <code>on chrome</code> i am getting.  <code>Error loading layout</code>
  I am getting TypeError</p>
  <pre><code>import dash_bootstrap_components as dbc
  from dash import dcc
  import dash_html_components as html
  from dash import dash_table
  import pandas as pd
  import numpy as np
  
  def getData():
      return preprocess()
  
  def back_to_df(dictio):
      return pd.DataFrame.from_dict(dictio)
  
  tblcols  =[{&quot;name&quot;: i, &quot;id&quot;: i} for i in back_to_df(getData()).columns]
  
  app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
  body = html.Div([
      html.H1(&quot;Live rates&quot;)
      , dbc.Row([
              dbc.Col(html.Div([dcc.Interval('graph-update', interval = 80, n_intervals = 0),
        dash_table.DataTable(
            id = 'table',
            data = getData(),
            columns=tblcols,
            page_size= 10,
            style_table={'overflowX': 'auto'},
        )]),width=3)
              ])
          ])
  app.layout = html.Div([body])
  
  @app.callback(
          dash.dependencies.Output('table','data'),
          [dash.dependencies.Input('graph-update', 'n_intervals')])
  def updateTable(n):
       return getData()
  
  if __name__ == &quot;__main__&quot;:
    app.run_server(debug = False, port = 8010)
  </code></pre>
  <p>I tried to fix the error but not able to fix, Can anyone look into this?
  I am getting error as follows.
  Looking for help for below error.  dash pandas plotly dataframe</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\flask\app.py&quot;, line 2447, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\flask\app.py&quot;, line 1952, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\flask\app.py&quot;, line 1821, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\flask\_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\flask\app.py&quot;, line 1950, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\flask\app.py&quot;, line 1936, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\dash\dash.py&quot;, line 569, in serve_layout
      to_json(layout),
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\dash\_utils.py&quot;, line 20, in to_json
      return to_json_plotly(value)
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\plotly\io\_json.py&quot;, line 124, in to_json_plotly
      return json.dumps(plotly_object, cls=PlotlyJSONEncoder, **opts)
    File &quot;C:\Users\Admin\anaconda3\lib\json\__init__.py&quot;, line 234, in dumps
      return cls(
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\_plotly_utils\utils.py&quot;, line 59, in encode
      encoded_o = super(PlotlyJSONEncoder, self).encode(o)
    File &quot;C:\Users\Admin\anaconda3\lib\json\encoder.py&quot;, line 199, in encode
      chunks = self.iterencode(o, _one_shot=True)
    File &quot;C:\Users\Admin\anaconda3\lib\json\encoder.py&quot;, line 257, in iterencode
      return _iterencode(o, 0)
    File &quot;C:\Users\Admin\anaconda3\lib\site-packages\_plotly_utils\utils.py&quot;, line 136, in default
      return _json.JSONEncoder.default(self, obj)
    File &quot;C:\Users\Admin\anaconda3\lib\json\encoder.py&quot;, line 179, in default
      raise TypeError(f'Object of type {o.__class__.__name__} '
  
  TypeError: Object of type DataFrame is not JSON serializable```
  </code></pre>