> For the complete documentation index, see [llms.txt](https://danfo.jsdata.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://danfo.jsdata.org/api-reference/series/series.replace.md).

# Series.replace

> 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. | <p>{</p><p>inplace: false</p><p>}</p> |

**Returns**: Series

**Examples**

### Replace a value in a series and return a new series

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

```javascript
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 %}

### Replace a value in-place

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

```javascript
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 ║
╚═══╧═════╝
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://danfo.jsdata.org/api-reference/series/series.replace.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
