Skip to content

Commit 7cc56c2

Browse files
committed
Update _core.py
1 parent 9154a67 commit 7cc56c2

File tree

1 file changed

+11
-4
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+11
-4
lines changed

Diff for: 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

0 commit comments

Comments
 (0)