Powered By GitBook
Series.argsort
Return the integer indices that would sort the Series values
danfo.Series.argsort(options) [source]
Parameters
Type
Description
Default
options
Object
ascending: How to sort the indices
{ ascending: true
}
Returns: Series (int element)
Example
Node
1
const dfd = require("danfojs-node")
2
3
let data = [10, 45, 20, 10, 23, 20, 30, 11]
4
let sf = new dfd.Series(data)
5
6
sf.argsort().print() //defaults to ascending order
7
sf.argsort({ ascending: false }).print()
8
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ 0 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 3 ║
7
╟───┼──────────────────────╢
8
║ 2 │ 7 ║
9
╟───┼──────────────────────╢
10
║ 3 │ 2 ║
11
╟───┼──────────────────────╢
12
║ 4 │ 5 ║
13
╟───┼──────────────────────╢
14
║ 5 │ 4 ║
15
╟───┼──────────────────────╢
16
║ 6 │ 6 ║
17
╟───┼──────────────────────╢
18
║ 7 │ 1 ║
19
╚═══╧══════════════════════╝
20
21
//sorted in descending order
22
╔═══╤═══╗
23
║ 0 │ 1 ║
24
╟───┼───╢
25
║ 1 │ 6 ║
26
╟───┼───╢
27
║ 2 │ 4 ║
28
╟───┼───╢
29
║ 3 │ 2 ║
30
╟───┼───╢
31
║ 4 │ 5 ║
32
╟───┼───╢
33
║ 5 │ 7 ║
34
╟───┼───╢
35
║ 6 │ 0 ║
36
╟───┼───╢
37
║ 7 │ 3 ║
38
╚═══╧═══╝
Copied!
Last modified 13d ago
Copy link