DataFrame.sortIndex

Sort DataFrame by index

DataFrame.sortIndex(options) [source]

Parameters
Type
Description
Default

options

Object

{

ascending: Sorting order.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

{ascending: true, **inplace:**false}

Returns:

**** return DataFrame

Examples

Sort DataFrame by a column in ascending order

const dfd = require("danfojs-node")

let data = [[0, 2, 4, "b"],
            [360, 180, 360, "a"],
            [2, 4, 6, "c"]]

let df = new dfd.DataFrame(data, { "columns": ["col1", "col2", "col3", "col4"],
                           index: ["b", "a", "c"] })
df.print()

let df2 = df.sortIndex({ ascending: false })
df2.print()

Last updated

Was this helpful?