Series.map

Map the value of a series to a function or Object

danfo.series.map(callable)

ParameterTypeDescriptionDefault

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

const dfd = require("danfojs-node")

let sf = new dfd.Series([1, 2, 3, 4])
let map = { 1: "ok", 2: "okie", 3: "frit", 4: "gop" }
sf.map(map).print()
╔═══╤══════╗
║ 0 │ ok   ║
╟───┼──────╢
║ 1 │ okie ║
╟───┼──────╢
║ 2 │ frit ║
╟───┼──────╢
║ 3 │ gop  ║
╚═══╧══════╝

Mapping values in a Series to a representation using functions.

const dfd = require("danfojs-node")

let sf = new dfd.Series([1,2,3,4])

sf.map((x)=>{
    return `I have ${x} cat(s)`
}).print()
╔═══╤═════════════════╗
║ 0 │ I have 1 cat(s) ║
╟───┼─────────────────╢
║ 1 │ I have 2 cat(s) ║
╟───┼─────────────────╢
║ 2 │ I have 3 cat(s) ║
╟───┼─────────────────╢
║ 3 │ I have 4 cat(s) ║
╚═══╧═════════════════╝

Last updated