-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Sunburst/treemap path #2006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sunburst/treemap path #2006
Changes from 1 commit
4ac1efb
c619e28
10668b6
edfcced
1f3b8da
8cb9d99
cd500a5
c233220
edefabf
41c8d30
2952fe6
c6b7243
be3b622
7f2920b
8519302
437bbd7
fb9d992
a57b027
bf8da4b
9e23890
f67602f
6b6a105
9996731
f3e7e27
8cd227a
8b66c90
19b81ac
ba6ec19
c0cbce0
57503b4
0ab2afd
0d86998
d63d4bd
9b217f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1007,14 +1007,6 @@ def build_dataframe(args, attrables, array_attrables): | |
return args | ||
|
||
|
||
def _named_agg(colname, aggfunc, mode="old_pandas"): | ||
if mode == "old_pandas": | ||
return (colname, aggfunc) | ||
else: | ||
# switch to this mode when tuples become deprecated | ||
return pd.NamedAgg(colname, aggfunc) | ||
|
||
|
||
def process_dataframe_hierarchy(args): | ||
""" | ||
Build dataframe for sunburst or treemap when the path argument is provided. | ||
|
@@ -1054,15 +1046,15 @@ def process_dataframe_hierarchy(args): | |
aggfunc_color = lambda x: np.average( | ||
x, weights=df.loc[x.index, count_colname] | ||
) | ||
agg_f[args["color"]] = _named_agg(colname=args["color"], aggfunc=aggfunc_color) | ||
agg_f[args["color"]] = aggfunc_color | ||
if args["color"] or args["values"]: | ||
agg_f[count_colname] = _named_agg(colname=count_colname, aggfunc="sum") | ||
agg_f[count_colname] = "sum" | ||
|
||
# Other columns (for color, hover_data, custom_data etc.) | ||
cols = list(set(df.columns).difference(path)) | ||
for col in cols: # for hover_data, custom_data etc. | ||
if col not in agg_f: | ||
agg_f[col] = _named_agg(colname=col, aggfunc=lambda_discrete) | ||
agg_f[col] = lambda_discrete | ||
# ---------------------------------------------------------------------------- | ||
|
||
df_all_trees = pd.DataFrame(columns=["labels", "parent", "id"] + cols) | ||
|
@@ -1074,7 +1066,7 @@ def process_dataframe_hierarchy(args): | |
if not agg_f: | ||
dfg = df.groupby(path[i:]).sum(numerical_only=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. under what circumstances do we do this, and what's the reasoning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's if neither There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could get rid of this part with the |
||
else: | ||
dfg = df.groupby(path[i:]).agg(**agg_f) | ||
dfg = df.groupby(path[i:]).agg(agg_f) | ||
dfg = dfg.reset_index() | ||
df_tree["labels"] = dfg[level].copy().astype(str) | ||
df_tree["parent"] = "" | ||
|
Uh oh!
There was an error while loading. Please reload this page.