Skip to content

Commit 4628ee6

Browse files
committed
Merge branch 'master' into release-5.19.0
2 parents b541a69 + 2451671 commit 4628ee6

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

packages/python/plotly/plotly/express/_core.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
_subplot_type_for_trace_type,
1818
)
1919

20+
pandas_2_2_0 = version.parse(pd.__version__) >= version.parse("2.2.0")
21+
2022
NO_COLOR = "px_no_color_constant"
2123
trendline_functions = dict(
2224
lowess=lowess, rolling=rolling, ewm=ewm, expanding=expanding, ols=ols
@@ -2068,10 +2070,15 @@ def get_groups_and_orders(args, grouper):
20682070
g.insert(i, "")
20692071
full_sorted_group_names = [tuple(g) for g in full_sorted_group_names]
20702072

2071-
groups = {
2072-
sf: grouped.get_group(s if len(s) > 1 else s[0])
2073-
for sf, s in zip(full_sorted_group_names, sorted_group_names)
2074-
}
2073+
groups = {}
2074+
for sf, s in zip(full_sorted_group_names, sorted_group_names):
2075+
if len(s) > 1:
2076+
groups[sf] = grouped.get_group(s)
2077+
else:
2078+
if pandas_2_2_0:
2079+
groups[sf] = grouped.get_group((s[0],))
2080+
else:
2081+
groups[sf] = grouped.get_group(s[0])
20752082
return groups, orders
20762083

20772084

packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from plotly.express._core import build_dataframe
99
from pandas.testing import assert_frame_equal
1010
import sys
11+
import warnings
1112

1213

1314
# Fixtures
@@ -667,3 +668,16 @@ def test_x_or_y(fn):
667668
assert list(fig.data[0].x) == constant
668669
assert list(fig.data[0].y) == categorical
669670
assert fig.data[0].orientation == "h"
671+
672+
673+
def test_no_futurewarning():
674+
with warnings.catch_warnings(record=True) as warn_list:
675+
_ = px.scatter(
676+
x=[15, 20, 29],
677+
y=[10, 20, 30],
678+
color=["Category 1", "Category 2", "Category 1"],
679+
)
680+
future_warnings = [
681+
warn for warn in warn_list if issubclass(warn.category, FutureWarning)
682+
]
683+
assert len(future_warnings) == 0, "FutureWarning(s) raised!"

packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
requests==2.25.1
22
tenacity==6.2.0
3-
pandas==2.0.2
4-
numpy==1.21.6
3+
pandas==2.2.0
4+
numpy==1.22.4
55
xarray==0.17.0
66
statsmodels
77
Pillow==8.2.0

0 commit comments

Comments
 (0)