description |
---|
Map the value of a series to a function or Object |
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 %}