vivainsights.create_sankey¶
Create a Sankey chart from a two-column count table.
- vivainsights.create_sankey.create_sankey(data, var1, var2, count='n')[source]¶
Create a Sankey diagram from a long count table.
The input data should have at least three columns: two categorical variables and a count column, where each row represents a unique group combination.
- Parameters:
data (pandas.DataFrame) – Long count table.
var1 (str) – Column name for the variable shown on the left.
var2 (str) – Column name for the variable shown on the right.
count (str, default "n") – Column name containing the count values.
- Returns:
Displays an interactive Plotly Sankey diagram.
- Return type:
None
Examples
Create a Sankey diagram from a person query dataset:
>>> import vivainsights as vi >>> pq_data = vi.load_pq_data() >>> agg = pq_data.groupby(["Organization", "FunctionType"]).agg(n=("PersonId", "nunique")).reset_index() >>> vi.create_sankey(data=agg, var1="Organization", var2="FunctionType", count="n")
Use a custom count column:
>>> vi.create_sankey(data=agg, var1="Organization", var2="FunctionType", count="n")