Powered By GitBook
Series.map
Map the value of a series to a function or Object
danfo.series.map(callable) [source]
Parameter
Type
Description
Default
callable
Function or Object
A function or object({})
options
Object
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
{
inplace: false
}
Example
Mapping the element in a Series words in an Object
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let sf = new dfd.Series([1, 2, 3, 4])
4
let map = { 1: "ok", 2: "okie", 3: "frit", 4: "gop" }
5
sf.map(map).print()
6
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ ok ║
5
╟───┼──────────────────────╢
6
║ 1 │ okie ║
7
╟───┼──────────────────────╢
8
║ 2 │ frit ║
9
╟───┼──────────────────────╢
10
║ 3 │ gop ║
11
╚═══╧══════════════════════╝
Copied!
Mapping values in a Series to a representation using functions.
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let sf = new dfd.Series([1,2,3,4])
4
5
sf.map((x)=>{
6
return `I have ${x} cat(s)`
7
}).print()
8
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ I have 1 cat(s) ║
5
╟───┼──────────────────────╢
6
║ 1 │ I have 2 cat(s) ║
7
╟───┼──────────────────────╢
8
║ 2 │ I have 3 cat(s) ║
9
╟───┼──────────────────────╢
10
║ 3 │ I have 4 cat(s) ║
11
╚═══╧══════════════════════╝
Copied!
Last modified 24d ago
Copy link