Skip to content

Commit

Permalink
Update _core.py
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamConnors committed Feb 13, 2024
1 parent 9154a67 commit 7cc56c2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
_subplot_type_for_trace_type,
)

pandas_2_2_0 = version.parse(pd.__version__) >= version.parse("2.2.0")

NO_COLOR = "px_no_color_constant"
trendline_functions = dict(
lowess=lowess, rolling=rolling, ewm=ewm, expanding=expanding, ols=ols
Expand Down Expand Up @@ -2068,10 +2070,15 @@ def get_groups_and_orders(args, grouper):
g.insert(i, "")
full_sorted_group_names = [tuple(g) for g in full_sorted_group_names]

groups = {
sf: grouped.get_group(s if len(s) > 1 else s[0])
for sf, s in zip(full_sorted_group_names, sorted_group_names)
}
groups = {}
for sf, s in zip(full_sorted_group_names, sorted_group_names):
if len(s) > 1:
groups[sf] = grouped.get_group(s)
else:
if pandas_2_2_0:
groups[sf] = grouped.get_group((s[0],))
else:
groups[sf] = grouped.get_group(s[0])
return groups, orders


Expand Down

0 comments on commit 7cc56c2

Please sign in to comment.