Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 1.03 KB

danfo.series.set_index.md

File metadata and controls

40 lines (27 loc) · 1.03 KB
description
Assign new Index to Series

danfo.Series.set_index

danfo.series.set_index(kwargs) [source]

Parameters Type Description Default
kwargs Object {} The object contains the key index and assigned an array value of equal length to the Series. format {"index": [Array] }

Example

const dfd = require("danfojs")

let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }]
let df = new dfd.Series(data)
let df_new = df.set_index({ "index": ["one", "two", "three"] })
df_new.print()

OUTPUT

const dfd = require("danfojs")

let data = ["Humans","Life","Meaning","Fact","Truth"]
let df = new dfd.Series(data)
let df_new = df.set_index({ "index": ["H", "L", "M","F","T"] })
df_new.print()

OUTPUT