title: Can't get graphical map to display; IndexError: index 4 is out of bounds for axis 0 with size 0
body: <p>So I'm working on an interactive dashboard using Jupyter Plotly Dash, where I am importing a database from MongoDB. I am trying to get a geographical map to display underneath my data table, however it does not appear. I took a look at the terminal running Jupyter Notebook, and I did take note of an error; IndexError: index 4 is out of bounds for axis 0 with size 0. I am not entirely sure if this error is relevant to my problem or not. I did some research on this type of error, and from my understanding, it would usually occur if there is no data within the python list. I'm especially curious as to why it is saying there is an axis 0 with size 0, as I expected my code to have a size of 14. I guess what is confusing me is the fact that my dataset seems to import itself correctly, as the data table fills itself with data as expected. I'm still learning this, so any advice in the right direction would be appreciated.</p>
  <pre><code>from jupyter_plotly_dash import JupyterDash
  
  import dash
  import dash_leaflet as dl
  from dash import html, dcc, dash_table
  import plotly.express as px
  from dash.dependencies import Input, Output, State
  import base64
  import os
  import numpy as np
  import pandas as pd
  from pymongo import MongoClient
  from bson.json_util import dumps
  import matplotlib.pyplot as plt
  
  from pyth_script import CustomDashboard
  
  ###########################
  # Data Manipulation / Model
  ###########################
  # User authentication
  username = &quot;myuser&quot;
  password = &quot;teambds&quot;
  pyths = CustomDashboard(username, password)
  
  # Convert PyMongo cursor into Pandas DataFrame
  df = pd.DataFrame(list(pyths.read_all({})))
  
  #########################
  # Dashboard Layout / View
  #########################
  app = JupyterDash('ANM Database')
  
  # Declare the application interfaces
  app.layout = html.Div([
      html.Div(id='hidden-div', style={'display':'none'}),
      html.Center(html.B(html.H1('Custom Dashboard'))),
      html.Hr(),
      dash_table.DataTable(
          id='datatable-id',
          columns=[
              {&quot;name&quot;: i, &quot;id&quot;: i, &quot;deletable&quot;: False, &quot;selectable&quot;: True} for i in df.columns
          ],
          data=df.to_dict('records'),
          editable=False,
          filter_action=&quot;native&quot;,
          row_selectable=&quot;single&quot;,
          selected_columns=[],
          page_size = 15
  
      ),
      html.Br(),
       html.Hr(),
       html.Div(
              id='map-id',
              className='col s12 m6',
              )
  ])
  
  #############################################
  # Interaction Between Components / Controller
  #############################################
  @app.callback(
      Output('datatable-id', 'style_data_conditional'),
      [Input('datatable-id', 'selected_columns')]
  )
  def update_styles(selected_columns):
      return [{
          'if': { 'column_id': i },
          'background_color': '#D2F3FF'
      } for i in selected_columns]
  
  
  @app.callback(
      Output('map-id', &quot;children&quot;),
      [Input('datatable-id', &quot;derived_viewport_data&quot;)])
  def update_map(viewData):
      dff = pd.DataFrame.from_dict(viewData)
      return [
          dl.Map(style={'width': '1000px', 'height': '500px'}, center=[30.75,-97.48], zoom=10, children=[
              dl.TileLayer(id=&quot;base-layer-id&quot;),
              # Marker with tool tip and popup
              dl.Marker(position=[30.75,-97.48], children=[
                  dl.Tooltip(dff.iloc[0,4]),
                  dl.Popup([
                      html.H1(&quot;Name&quot;),
                      html.P(dff.iloc[1,9])
                  ])
              ])
          ])
      ]
  
  app
  </code></pre>
  <p>The compiled result;
  <a href="https://cdn.discordapp.com/attachments/684573403625160704/964591129465085962/Screen_Shot_2022-04-15_at_2.19.43_PM.png" rel="nofollow noreferrer">https://cdn.discordapp.com/attachments/684573403625160704/964591129465085962/Screen_Shot_2022-04-15_at_2.19.43_PM.png</a>
  <a href="https://cdn.discordapp.com/attachments/684573403625160704/964591113384128612/Screen_Shot_2022-04-15_at_2.19.52_PM.png" rel="nofollow noreferrer">https://cdn.discordapp.com/attachments/684573403625160704/964591113384128612/Screen_Shot_2022-04-15_at_2.19.52_PM.png</a></p>
  <p>The full error trace;</p>
  <pre><code>[I 10:14:29.662 NotebookApp] Kernel started: 20a09017-8a0c-4fa0-9297-6f1d6f433faf, name: python3
  [IPKernelApp] ERROR | Exception in comm_msg for 64c788f60e65402e9c8bec7feb95a8a3
  Traceback (most recent call last):
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/ipykernel/comm/manager.py&quot;, line 109, in comm_msg
      comm.handle_msg(msg)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/ipykernel/comm/comm.py&quot;, line 161, in handle_msg
      self._msg_callback(msg)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/jupyter_plotly_dash/nbkernel.py&quot;, line 47, in callback
      response, mimetype = app.process_view(stem, args, app_path)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/jupyter_plotly_dash/dash_wrapper.py&quot;, line 152, in process_view
      resp, rmt = func(args, app_path, view_name_parts)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/jupyter_plotly_dash/dash_wrapper.py&quot;, line 193, in rv__dash_update_component
      resp = dapp.dispatch_with_args(args, argMap)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/django_plotly_dash/dash_wrapper.py&quot;, line 698, in dispatch_with_args
      res = callback(*args, **{k: v for k, v in argMap.items() if k in parameters_to_inject})
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/dash/_callback.py&quot;, line 151, in add_context
      output_value = func(*func_args, **func_kwargs)  # %% callback invoked %%
    File &quot;/var/folders/n6/3w8lx4ds5cn4kybq464lmrww0000gn/T/ipykernel_82408/3817460729.py&quot;, line 88, in update_map
      dl.Tooltip(dff.iloc[0,4]),
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexing.py&quot;, line 960, in __getitem__
      return self.obj._get_value(*key, takeable=self._takeable)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py&quot;, line 3612, in _get_value
      series = self._ixs(col, axis=1)
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py&quot;, line 3439, in _ixs
      label = self.columns[i]
    File &quot;/Users/jake/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py&quot;, line 5039, in __getitem__
      return getitem(key)
  IndexError: index 4 is out of bounds for axis 0 with size 0
  </code></pre>