rank(self, method: 'str' = 'average', ascending: 'bool' = True, na_option: 'str' = 'keep', pct: 'bool' = False, axis: 'int' = 0)
average: average rank of group.
min: lowest rank in group.
max: highest rank in group.
first: ranks assigned in order they appear in the array.
dense: like 'min', but rank always increases by 1 between groups.
False for ranks by high (1) to low (N).
keep: leave NA values where they are.
top: smallest rank if ascending.
bottom: smallest rank if descending.
Compute percentage rank of data within each group.
The axis of the object over which to compute the rank.
Provide the rank of values within each group.
DataFrame.groupby
Apply a function groupby to each row or column of a DataFrame.
Series.groupby
Apply a function groupby to a Series.
>>> df = pd.DataFrame(This example is valid syntax, but we were not able to check execution
... {
... "group": ["a", "a", "a", "a", "a", "b", "b", "b", "b", "b"],
... "value": [2, 4, 2, 3, 5, 1, 2, 4, 1, 5],
... }
... )
... df group value 0 a 2 1 a 4 2 a 2 3 a 3 4 a 5 5 b 1 6 b 2 7 b 4 8 b 1 9 b 5
>>> for method in ['average', 'min', 'max', 'dense', 'first']:See :
... df[f'{method}_rank'] = df.groupby('group')['value'].rank(method)
... df group value average_rank min_rank max_rank dense_rank first_rank 0 a 2 1.5 1.0 2.0 1.0 1.0 1 a 4 4.0 4.0 4.0 3.0 4.0 2 a 2 1.5 1.0 2.0 1.0 2.0 3 a 3 3.0 3.0 3.0 2.0 3.0 4 a 5 5.0 5.0 5.0 4.0 5.0 5 b 1 1.5 1.0 2.0 1.0 1.0 6 b 2 3.0 3.0 3.0 2.0 3.0 7 b 4 4.0 4.0 4.0 3.0 4.0 8 b 1 1.5 1.0 2.0 1.0 2.0 9 b 5 5.0 5.0 5.0 4.0 5.0
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them