plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Incorrect interpretation of nullable data types

Open sergiykhan opened this issue 3 years ago • 4 comments

Description

Using Pandas' nullable data types (Int64 and Float64) result in an incorrect plot.

Code

import pandas as pd
import plotly.express as px
df = pd.DataFrame(
    data=[1,2,3,4,5],
    columns=['a'],
    index=pd.date_range('2021-01-01', '2021-01-05'),
    dtype='Int64',
)

px.bar(df)

Result

wrong

Expected

correct

sergiykhan avatar Dec 02 '21 18:12 sergiykhan

Cannot reproduce in plotly '5.16.1', must've been fixed in or before this version.

avm19 avatar Jan 16 '24 00:01 avm19

I have plotly 5.18.0 installed right now, and the problem is still there.

sergiykhan avatar Jan 16 '24 01:01 sergiykhan

I have plotly 5.18.0 installed right now, and the problem is still there.

I tried in plotly version 5.18.0, but to no avail. Maybe it depends on other packages in a tricky way.

import pandas as pd
import plotly.express as px
import plotly
df = pd.DataFrame(
    data=[1,2,3,4,5],
    columns=['a'],
    index=pd.date_range('2021-01-01', '2021-01-05'),
    dtype='Int64'
)

px.bar(df, height=300, title=plotly.__version__ + '; ' + pd.__version__)

newplot

avm19 avatar Jan 16 '24 02:01 avm19

Ah, I am still running Pandas 1.5.3 (due to bugs in 2.x related to timestamp resolution). So, I suppose some issues related to nullable types got fixed in Pandas 2.x.

1 2

sergiykhan avatar Jan 16 '24 02:01 sergiykhan

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

gvwilson avatar Jul 11 '24 13:07 gvwilson