DataFrame.addColumn
Add new column to a DataFrame
danfo.DataFrame.addColumn(column**,** values**,** options)
Parameters
Type
Description
Default
column
String
Name of the column to add.
values
Series**,** Array
New values to add
options
Object
inplace: Whether to perform the operation inplace or not.
Default to false.
Returns:
Examples
Add Array as a new column to DataFrame
New columns get added at the end of the DataFrame.
const dfd = require("danfojs-node")
let data = {
"A": [30, 1, 2, 3],
"B": [34, 4, 5, 6],
"C": [20, 20, 30, 40]
}
let df = new dfd.DataFrame(data)
df.print()
let new_col = [1, 2, 3, 4]
df.addColumn("D", new_col, { inplace: true });
df.print()Add Series as a new column to DataFrame
Last updated
Was this helpful?