Skip to content

Latest commit

Β 

History

History
86 lines (71 loc) Β· 2.29 KB

series.map.md

File metadata and controls

86 lines (71 loc) Β· 2.29 KB
description
Map the value of a series to a function or Object

Series.map

danfo.series.map(callable)

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

{% tabs %} {% tab title="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()

{% endtab %}

{% tab title="Browser" %}

{% endtab %} {% endtabs %}

{% tabs %} {% tab title="Output" %}

╔═══╀══════╗
β•‘ 0 β”‚ ok   β•‘
β•Ÿβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β•’
β•‘ 1 β”‚ okie β•‘
β•Ÿβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β•’
β•‘ 2 β”‚ frit β•‘
β•Ÿβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β•’
β•‘ 3 β”‚ gop  β•‘
β•šβ•β•β•β•§β•β•β•β•β•β•β•

{% endtab %} {% endtabs %}

Mapping values in a Series to a representation using functions.

{% tabs %} {% tab title="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()

{% endtab %}

{% tab title="Browser" %}

{% endtab %} {% endtabs %}

{% tabs %} {% tab title="Output" %}

╔═══╀═════════════════╗
β•‘ 0 β”‚ I have 1 cat(s) β•‘
β•Ÿβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ 1 β”‚ I have 2 cat(s) β•‘
β•Ÿβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ 2 β”‚ I have 3 cat(s) β•‘
β•Ÿβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ 3 β”‚ I have 4 cat(s) β•‘
β•šβ•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

{% endtab %} {% endtabs %}