Skip to content
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

Pandas 2 compability: Fix a bug regarding timedelta64[ms] representation #4102 #4103

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ jobs:
- test_optional:
py: "39"

# Pandas

python_39_pandas_2_optional:
docker:
- image: circleci/python:3.9-buster-node-browsers
steps:
- test_optional:
py: "39_pandas_2"

# Orca
python_38_orca:
docker:
Expand Down Expand Up @@ -470,6 +479,7 @@ workflows:
- python_37_optional
- python_38_optional
- python_39_optional
- python_39_pandas_2_optional
- python_38_orca
- python_37_percy
- build-doc
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [5.X.X] - 2023-MM-DD
- Support for pandas 2.0 [[#4103](https://github.com/plotly/plotly.py/pull/4103)]

## [5.14.0] - 2023-03-29

### Updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def color_validator(request):
"uint16",
"uint32",
"uint64",
"float16",
# "float16",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson Python 2.0 forbids creating float16 indxes:

image

The easiest thing to do would be to drop this line here.

"float32",
"float64",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def color_validator(request):
"uint16",
"uint32",
"uint64",
"float16",
# "float16",
"float32",
"float64",
]
Expand Down
3 changes: 2 additions & 1 deletion packages/python/plotly/plotly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def plot(data_frame, kind, **kwargs):
if kind == "line":
return line(data_frame, **kwargs)
if kind == "area":
return area(data_frame, **kwargs)
new_kwargs = {k: kwargs[k] for k in kwargs if k not in ["stacked"]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a question for @nicolaskruchten as much as for you @kaibir - since there are already other examples of these exclusions in other kinds, but how do we know what needs to be excluded?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It raised in a test 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah in principle the Pandas team isn't meant to add kwargs or mess with that API much any more but if/when they do (by e.g. adding upstream kwargs) then our tests will fail.

return area(data_frame, **new_kwargs)
if kind == "bar":
return bar(data_frame, **kwargs)
if kind == "barh":
Expand Down
4 changes: 3 additions & 1 deletion packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,9 @@ def process_dataframe_timeline(args):
)

# note that we are not adding any columns to the data frame here, so no risk of overwrite
args["data_frame"][args["x_end"]] = (x_end - x_start).astype("timedelta64[ms]")
args["data_frame"][args["x_end"]] = (x_end - x_start).astype(
"timedelta64[ns]"
) / np.timedelta64(1, "ms")
args["x"] = args["x_end"]
del args["x_end"]
args["base"] = args["x_start"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import numpy as np
import pandas as pd
import pytz
from pandas.util.testing import assert_series_equal
from pandas.testing import assert_series_equal
import json as _json
import os
import base64
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
requests==2.25.1
tenacity==6.2.0
pandas==2.0.0
numpy==1.20.3
xarray==0.17.0
statsmodels
Pillow==8.2.0
pytest==6.2.3
pytz==2021.1
ipython[all]==7.22.0
ipywidgets==8.0.2
ipykernel==5.5.3
jupyter==1.0.0
scipy==1.6.2
Shapely==1.7.1
geopandas==0.9.0
pyshp==2.1.3
matplotlib==2.2.3
scikit-image==0.18.1
psutil==5.7.0
kaleido