DataFrame.index

The index (row labels) of the DataFrame.

danfo.DataFrame.index [source]

Returns:

return new DataFrame

Examples

Returns auto-generated index of a DataFrame

Node
Browser
Node
const dfd = require("danfojs-node")
let data = {"A": [-20.1, 30, 47.3, -20],
"B": [34, -4, 5, 6],
"C": [20, -20, 30, -40]}
let df = new dfd.DataFrame(data)
console.log(df.index);
Browser
Output
Output
[0, 1, 2, 3]

Returns set index of a DataFrame

Node
Browser
Node
const dfd = require("danfojs-node")
let data = {"A": [-20.1, 30, 47.3, -20],
"B": [34, -4, 5, 6],
"C": [20, -20, 30, -40]}
let df = new dfd.DataFrame(data, {index: ["r1", "r2", "r3", "r4"])
console.log(df.index);
Browser
Output
Output
[ 'r1', 'r2', 'r3', 'r4' ]