0

I am plotting my Dataframe using Plotly but for some reason, my Datetime values gets converted numbers instead of getting displayed as letters

    fig.add_trace(go.Scatter(x=df2plt["PyDate"].values,
                         y=df2plt["Data"].values))

enter image description here

1
  • Dimo you have a sample of those date? Commented Jan 24, 2020 at 7:25

1 Answer 1

1

If df2plt["PyDate"] is already in datetime format:

fig.add_trace(go.Scatter(x=df2plt["PyDate"],
                     y=df2plt["Data"].values))

Else:

fig.add_trace(go.Scatter(x=pd.to_datetime(df2plt["PyDate"]) ,
                     y=df2plt["Data"].values)) 

You can change the display with the variable format:

*format : string, default None strftime to parse time, eg “%d/%m/%Y”, note that “%f” will parse all the way up to nanoseconds. See strftime documentation for more information on choices: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior *

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.