Series.resetIndex
Reset the index of a series.
danfo.series.resetIndex(options)
Parameters
Type
Description
Default
options
Object
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
{ inplace:false}
resetIndex is useful when the index needs to be treated as a column, or when the index is meaningless and needs to be reset to default, before another operation.
Reset index to default values
const dfd = require("danfojs-node")
let data = [20, 30, 40]
let sf = new dfd.Series(data, { index: ["a", "b", "c"] })
sf.print()
let sf_reset = sf.resetIndex()
sf_reset.print()╔═══╤════╗
║ a │ 20 ║
╟───┼────╢
║ b │ 30 ║
╟───┼────╢
║ c │ 40 ║
╚═══╧════╝
╔═══╤════╗
║ 0 │ 20 ║
╟───┼────╢
║ 1 │ 30 ║
╟───┼────╢
║ 2 │ 40 ║
╚═══╧════╝Reset index to new values in-place
Last updated
Was this helpful?