Series.map

Map the value of a series to it representation

danfo.series.map(callable) [source]

Parameter

Type

Description

Default

callable

Function or Object

callable can either be a function or an object({})

Example

Mapping the element in a Series to a word

Node
Browser
Node
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()
Browser
Output
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ 0 │ ok ║
╟───┼──────────────────────╢
║ 1 │ okie ║
╟───┼──────────────────────╢
║ 2 │ frit ║
╟───┼──────────────────────╢
║ 3 │ gop ║
╚═══╧══════════════════════╝

Mapping values in a Series to a representation using functions.

Node
Browser
Node
const dfd = require("danfojs-node")
let sf = new dfd.Series([1,2,3,4])
sf.map((x)=>{
return `I have ${x} cat(s)`
}).print()
Browser
Output
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ 0 │ I have 1 cat(s) ║
╟───┼──────────────────────╢
║ 1 │ I have 2 cat(s) ║
╟───┼──────────────────────╢
║ 2 │ I have 3 cat(s) ║
╟───┼──────────────────────╢
║ 3 │ I have 4 cat(s) ║
╚═══╧══════════════════════╝