Skip to content

px.timeline hoverdata not working as intended #2930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sliskorm opened this issue Nov 23, 2020 · 2 comments
Closed

px.timeline hoverdata not working as intended #2930

Sliskorm opened this issue Nov 23, 2020 · 2 comments

Comments

@Sliskorm
Copy link

then i run this code below i get:
ValueError: Value of 'hover_data_1' is not the name of a column in 'data_frame'. Expected one of ['start_x', 'end_y', 'Hoverdata', 'H', 'y'] but received: o

#pip install plotly
#pip install pandas
#pip install xlrd

import plotly.express as px
import pandas as pd
df=pd.read_excel('bug.xls')
print(df)

fig=px.timeline
(data_frame=df,
x_start='start_x',
x_end='end_y',
y='y',
hover_data='Hoverdata',
#hover_data='H',
)
fig.show()

but if i run this code it work.

#pip install plotly
#pip install pandas
#pip install xlrd

import plotly.express as px
import pandas as pd
df=pd.read_excel('bug.xls')
print(df)

fig=px.timeline
(data_frame=df,
x_start='start_x',
x_end='end_y',
y='y',
#hover_data='Hoverdata',
hover_data='H',
)
fig.show()

custom_data behaves the same way.

this is the df data i used
start_x end_y Hoverdata H y
0 2021-03-05 2020-05-16 00:00:00 text1 text1 name1
1 2021-03-06 2009-06-04 15:45:00 text2 text2 name2
2 2021-03-07 2009-06-04 15:45:00 text3 text3 name3
3 2021-03-08 2020-05-04 00:00:00 text4 text4 name4
4 2021-03-09 2020-05-06 00:00:00 text5 text5 name5
5 2021-03-10 2020-05-07 00:00:00 text6 text6 name6
6 2021-03-11 2020-05-07 00:00:00 text7 text7 name7
7 2021-03-12 2020-05-06 00:00:00 text8 text8 name8
8 2021-03-13 2019-05-13 00:00:00 text9 text9 name9
9 2021-03-14 2018-06-18 00:00:00 text10 text10 name10

@nicolaskruchten
Copy link
Contributor

Yes, hover_data accepts a list or a dict, not a string. We need a better error message for this :(

In fact we have an issue open to improve the error messages here: #2177

@Sliskorm
Copy link
Author

Darn i through it was bug. Closeing this One.
Idea
px.timeline(overwrite_hoverdata=columb in dataframe)
px.timeline(append_hoverdata=columb in dataframe)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants