You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible (nay, likely) that I'm misunderstanding something but the docs indicate that Numpy arrays containing timestamps should be allowed. Yet, I'm currently having to cast this into a Pandas Series for it to work:
# plotly date axis bug?importdashimportdash_core_componentsasdccimportdash_html_componentsashtmlimportplotly.graph_objectsasgoimportnumpyasnpimportpandasaspdapp=dash.Dash(__name__)
timestamps=np.array(
[
'2017-05-24T23:00:21',
'2017-05-24T23:00:23',
'2017-05-24T23:00:25',
'2017-05-24T23:00:27',
'2017-05-24T23:00:29'
],
dtype='datetime64[ns]'
)
fake_data=np.arange(len(timestamps))
fig_working=go.Figure().add_scatter(
x=pd.Series(timestamps),
y=fake_data
).update_layout(xaxis_type='date')
fig_working_not_so_much=go.Figure().add_scatter(
x=timestamps,
y=fake_data
).update_layout(xaxis_type='date')
app.layout=html.Div(
[
html.H1("Working with a pandas.Series:"),
dcc.Graph(figure=fig_working),
html.H1("Same data in a numpy.array:"),
dcc.Graph(figure=fig_working_not_so_much),
html.H1("😿")
]
)
if__name__=='__main__':
app.run_server(debug=True)
This yields:
The text was updated successfully, but these errors were encountered:
jordanweaver
changed the title
Using 'date' type for scatter xaxis fails when for coordinates stored in Numpy array
Using 'date' type for scatter xaxis fails when coordinates stored in Numpy array
Nov 25, 2019
So I'm moderately sure this has to do with the fact that pandas stores its datatime64[ns] internally as 'int64' where as numpy stores it as 'uint64'. It's supposed to be number of nanoseconds since epoch, so I can't imagine there would be a need for negative counts, but I don't know enough about the intent pandas had there.
It's possible (nay, likely) that I'm misunderstanding something but the docs indicate that Numpy arrays containing timestamps should be allowed. Yet, I'm currently having to cast this into a Pandas Series for it to work:
This yields:
The text was updated successfully, but these errors were encountered: