Powered By GitBook
Series.append
Add a new value or values to the end of a Series.
danfo.Series.append(newValue, index, options) [source]
Parameters
Type
Description
Default
newValue
Array, Series
Object to append
index
Array
The new index value(s) to append to the Series. Must contain the same number of values as newValues as they map 1 - 1.
options
Object
{ inplace: Whether to perform operation in-place or not.
}
false
Returns:
return Series

Append new Series to the end of a Series

Node
1
const dfd = require("danfojs-node")
2
3
let sf1 = new dfd.Series([1, 2, 3, 4], { index: ['f1', 'f2', 'f3', 'f4'] })
4
let sf2 = new dfd.Series(["a", "b", "c"])
5
6
new_sf = sf1.append(sf2, ["f5", "f6", "f7"])
7
new_sf.print()
Copied!
Output
1
╔════╤═══╗
2
║ f1 │ 1 ║
3
╟────┼───╢
4
║ f2 │ 2 ║
5
╟────┼───╢
6
║ f3 │ 3 ║
7
╟────┼───╢
8
║ f4 │ 4 ║
9
╟────┼───╢
10
║ f5 │ a ║
11
╟────┼───╢
12
║ f6 │ b ║
13
╟────┼───╢
14
║ f7 │ c ║
15
╚════╧═══╝
Copied!

Append new Series to the end of a Series in-place

Node
1
const dfd = require("danfojs-node")
2
3
let sf1 = new dfd.Series([1, 2, 3, 4], { index: ['f1', 'f2', 'f3', 'f4'] })
4
let sf2 = new dfd.Series(["a", "b", "c"])
5
let newIndex = ["f5", "f6", "f7"]
6
7
sf1.append(sf2, newIndex, { inplace: true })
8
sf1.print()
Copied!
1
╔════╤═══╗
2
║ f1 │ 1 ║
3
╟────┼───╢
4
║ f2 │ 2 ║
5
╟────┼───╢
6
║ f3 │ 3 ║
7
╟────┼───╢
8
║ f4 │ 4 ║
9
╟────┼───╢
10
║ f5 │ a ║
11
╟────┼───╢
12
║ f6 │ b ║
13
╟────┼───╢
14
║ f7 │ c ║
15
╚════╧═══╝
Copied!

Append an array to the end of Series

Node
Browser
1
let sf1 = new dfd.Series([1, 2, 3, 4], { index: ['f1', 'f2', 'f3', 'f4'] })
2
let sfArr = ["a", "b", "c"]
3
4
new_sf = sf1.append(sfArr, ["f5", "f6", "f7"])
5
new_sf.print()
6
Copied!
1
Copied!
Output
1
╔════╤═══╗
2
║ f1 │ 1 ║
3
╟────┼───╢
4
║ f2 │ 2 ║
5
╟────┼───╢
6
║ f3 │ 3 ║
7
╟────┼───╢
8
║ f4 │ 4 ║
9
╟────┼───╢
10
║ f5 │ a ║
11
╟────┼───╢
12
║ f6 │ b ║
13
╟────┼───╢
14
║ f7 │ c ║
15
╚════╧═══╝
16
Copied!
Last modified 24d ago