From e9be3dd5ec24017914cafaf15017375ef5dc7fab Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Wed, 16 Jun 2021 16:35:37 -0400 Subject: [PATCH] uniquify category_orders --- packages/python/plotly/plotly/express/_core.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index d9cc19cc061..a230cab8e23 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1829,14 +1829,11 @@ def get_orderings(args, grouper, grouped): orders = {} if "category_orders" not in args else args["category_orders"].copy() for col in grouper: if col != one_group: - uniques = args["data_frame"][col].unique() + uniques = list(args["data_frame"][col].unique()) if col not in orders: - orders[col] = list(uniques) + orders[col] = uniques else: - orders[col] = list(orders[col]) - for val in uniques: - if val not in orders[col]: - orders[col].append(val) + orders[col] = list(OrderedDict.fromkeys(list(orders[col]) + uniques)) sorted_group_names = [] for group_name in grouped.groups: