facet_vals.append(to_add.iloc[facet_rep, :])
// assign each point to a panel
facet_vals.drop_duplicates(inplace=True)
if len(facet_vals) == 0:
// Special case of no facetting
data["PANEL"] = 1
After Change
// Special case of no facetting
data["PANEL"] = 1
else:
keys_x = list(facet_vals.loc[:, vars].itertuples(index=False))
keys_y = list(panels.loc[:, vars].itertuples(index=False))
data["PANEL"] = match(keys_x, keys_y, start=1)
// matching dtype
data["PANEL"] = pd.Categorical(data["PANEL"])
data["PANEL"].cat.reorder_levels(panels["PANEL"].cat.levels)
data.sort(columns="PANEL", inplace=True)
return data