Is plotly handle missing data in pandas dataframe?

I am trying to create a box plot with plotly python but the graph is not showing. I have missing data in the columns that i am using in the graph. Is plotly handle missing data automatically or do i have to fill the missing values before creating the graphs.

For reference, here is my code for the box - plot

  1. Using Graph objects
fig = go.Figure()

fig.add_box(x= train['meter'], y= train['meter_reading'])

fig.update_layout(title='Meter Reading By Meter Type',
                 xaxis_title_text='Types of Meter',
                 yaxis_title_text='Meter Reading')
  1. Using plotly xpress
fig =, x='meter', y='meter_reading')

can anyone help me with this?

Hi @b_prasad26 welcome to the forum! Yes plotly can handle some kind of missing data, for example None or np.nan. For example the following examples produce valid plots (the None or np.nan) are just ignored.

import as px
import numpy as np
y = np.random.random(2000)
y[::2] = None 
fig =


import as px
import numpy as np
y = np.random.random(2000)
y[::2] = np.nan
fig =

What is the format of your missing data? You can use the fillna method of pandas dataframes to fill with None or np.nan.

1 Like

the format is np.nan but the plot is not showing. I couldn’t able to understand why?

Could you please share here a minimal standalone example? Also, could you take a look at the web developer console to see if there are error messages in Javascript ?


This is the plot I am trying to make. I did it using pandas. To create the same plot in plotly I used these codes -

fig =, x='meter', y='meter_reading')

No error message is showing, just the cell in notebook run but not plot is displayed.

ok, but I don’t have the data so I cannot reproduce the error. Could you please create a minimal dataframe within Python, including missing data, and post here a standalone code (ie one that I can run in my notebook) ? For the error message it would be in the Javascript console, which you open usually in the developer tools of your browser.

ok, give me a few minutes. I tried to run your example code and the plot is showing perfectly. I am trying to do the same with my own data but using only the the y variable this time. The dataframe is quite big, so it is taking some time. I will get back to you soon.

1 Like

ok, this error message I am getting from the javascript console -

Source map error: Error: request failed with status 404
Resource URL:
Source Map URL:

the link it is suggesting for learning more -