description |
---|
Replace values given in replace param with value |
danfo.Series.replace(oldValue, newValue, options)
Parameters | Type | Description | Default |
---|---|---|---|
oldValue | Any | The value you want to replace.
|
|
newValue | Any | The new value you want to replace with. | |
options | Object | inplace: Boolean, indicating whether to perform the operation inplace or not. | { inplace: false } |
Returns: Series
Examples
{% tabs %} {% tab title="Node" %}
const dfd = require("danfojs-node")
let data1 = [10, 45, 56, 25, 23, 20, 10]
let sf = new dfd.Series(data1)
let sf_rep = sf.replace(10, -50)
sf_rep.print()
{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Output" %}
╔═══╤═════╗
║ 0 │ -50 ║
╟───┼─────╢
║ 1 │ 45 ║
╟───┼─────╢
║ 2 │ 56 ║
╟───┼─────╢
║ 3 │ 25 ║
╟───┼─────╢
║ 4 │ 23 ║
╟───┼─────╢
║ 5 │ 20 ║
╟───┼─────╢
║ 6 │ -50 ║
╚═══╧═════╝
{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Node" %}
const dfd = require("danfojs-node")
let data1 = [10, 45, 56, 25, 23, 20, 10]
let sf = new dfd.Series(data1)
sf.replace(10, -50, { inplace: true})
sf.print()
{% endtab %} {% endtabs %}
╔═══╤═════╗
║ 0 │ -50 ║
╟───┼─────╢
║ 1 │ 45 ║
╟───┼─────╢
║ 2 │ 56 ║
╟───┼─────╢
║ 3 │ 25 ║
╟───┼─────╢
║ 4 │ 23 ║
╟───┼─────╢
║ 5 │ 20 ║
╟───┼─────╢
║ 6 │ -50 ║
╚═══╧═════╝