DataFrame.rename
Change axis labels. Object values must be unique (1-to-1). Labels not contained in a dict / Series will be left as-is. Extra labels listed don’t throw an error.
danfo.DataFrame.rename(mapper, options)
Parameters
Type
Description
Default
mapper
Object
Labels and transformations to apply to that axis’ values.
options
Object
axis: row=0, columns=1.
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
{
axis : 1,
inplace : false
}
Examples
Rename columns
By setting inplace to true, the original DataFrame is modified and nothing is returned. To not modify the original DataFrame and return a new one, set inplace to false or leave it as default.
const dfd = require("danfojs-node")
let data = {
"A": [-20, 30, 47.3],
"B": [34, -4, 5],
"C": [20, 2, 30]
}
let df = new dfd.DataFrame(data)
df.rename({ "A": "new_name" }, { inplace: true })
df.print()Rename more the one column at time
Rename index by labels
Last updated
Was this helpful?