danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

`sortValues` example is incorrect behavior

Open Lindenk opened this issue 3 years ago • 0 comments

Describe the bug The example for sortValues (https://danfo.jsdata.org/api-reference/dataframe/dataframe.sort_values) shows the following code:

const dfd = require("danfojs-node")

let data = { "A": [-20, 30, 47.3],
             "B": [34, 5, 6],
             "C": [20, 3, 30] }



let df = new dfd.DataFrame(data)
df.sortValues("C", { ascending: false, inplace: true })
df.print()

with this output:

╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ A                 │ B                 │ C                 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0          │ -20               │ 34                │ 20                ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2          │ 47.3              │ 6                 │ 30                ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1          │ 30                │ 5                 │ 3                 ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

To Reproduce Look at the docs.

Expected behavior The output should be:

╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ A                 │ B                 │ C                 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0          │ 47.3              │ 6                 │ 30                ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2          │ -20               │ 34                │ 20                ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1          │ 30                │ 5                 │ 3                 ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

Where values are sorted in descending order on the C column.

Lindenk avatar Sep 16 '22 19:09 Lindenk