> 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/dataframe/danfo.dataframe.mod.md).

# DataFrame.mod

danfo.DataFrame.mod(other, option)

| Parameters | Type                               | Description                                                                                                                                                                                  | Default                     |
| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| other      | DataFrame, Series, Array or Scalar | Object to modulo with                                                                                                                                                                        |                             |
| option     | Object                             | <p>{</p><p><strong>axis</strong>: 0 for row, 1 for column.</p><p><strong>inplace</strong>: Boolean indicating whether to perform the operation inplace or not. Defaults to false</p><p>}</p> | { axis: 1, inplace: false } |

## **Examples**

### Modulo of **scalar with** DataFrame along default axis 1

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

```javascript
const dfd = require("danfojs-node")

let data = {
    "Col1": [10, 45, 56, 10],
    "Col2": [23, 20, 10, 24]
}
let df = new dfd.DataFrame(data)

let df_new = df.mod(2)

df_new.print()
```

{% endtab %}

{% tab title="Browser" %}

```
```

{% endtab %}
{% endtabs %}

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

```
╔════════════╤═══════════════════╤═══════════════════╗
║            │ Col1              │ Col2              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 0                 │ 1                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ 1                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 2          │ 0                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 3          │ 0                 │ 0                 ║
╚════════════╧═══════════════════╧═══════════════════╝

```

{% endtab %}
{% endtabs %}

### Modulo of **Series with** DataFrame along axis 0

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

```javascript
const dfd = require("danfojs-node")

let data = {
    "Col1": [1, 4, 5, 1],
    "Col2": [3, 2, 0, 4]
}

let df = new dfd.DataFrame(data)
let sf = new dfd.Series([4, 5])

let df_new = df.mod(sf, { axis: 1 })

df_new.print()
```

{% endtab %}

{% tab title="Browser" %}

```
```

{% endtab %}
{% endtabs %}

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

```
╔════════════╤═══════════════════╤═══════════════════╗
║            │ Col1              │ Col2              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 1                 │ 3                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ 0                 │ 2                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 2          │ 1                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 3          │ 1                 │ 4                 ║
╚════════════╧═══════════════════╧═══════════════════╝

```

{% endtab %}
{% endtabs %}

### Modulo of DataFrame with a DataFrame

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

```javascript
const dfd = require("danfojs")

let data = {"Col1": [1, 4, 5, 0], 
            "Col2": [2, 0, 1, 4]}
            
let data2 = {"new_col1": [1, 5, 20, 10],
             "new_Col2": [20, 2, 1, 2]}

let df = new dfd.DataFrame(data)
let df2 = new dfd.DataFrame(data2)

let df_new = df.mod(df2)

df_new.print()
```

{% endtab %}

{% tab title="Browser" %}

```
```

{% endtab %}
{% endtabs %}

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

```
╔════════════╤═══════════════════╤═══════════════════╗
║            │ Col1              │ Col2              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 0                 │ 2                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ 4                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 2          │ 5                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 3          │ 0                 │ 0                 ║
╚════════════╧═══════════════════╧═══════════════════╝

```

{% endtab %}
{% endtabs %}

### Modulo of Array with DataFrame along axis 0

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

```javascript
const dfd = require("danfojs-node")

let data = {
    "Col1": [10, 45, 56, 10],
    "Col2": [23, 20, 10, 24]
}

let df = new dfd.DataFrame(data)
let val = [2, 2, 2, 2]

let df_new = df.mod(val, { axis: 0 })

df_new.print()
```

{% endtab %}

{% tab title="Browser" %}

```
```

{% endtab %}
{% endtabs %}

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

```
╔════════════╤═══════════════════╤═══════════════════╗
║            │ Col1              │ Col2              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 0                 │ 1                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ 1                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 2          │ 0                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 3          │ 0                 │ 0                 ║
╚════════════╧═══════════════════╧═══════════════════╝
```

{% endtab %}
{% endtabs %}

### Modulo works inplace

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

```javascript
const dfd = require("danfojs-node")

let data = {
    "Col1": [10, 45, 56, 10],
    "Col2": [23, 20, 10, 24]
}

let df = new dfd.DataFrame(data)
let val = [2, 2, 2, 2]

df.mod(val, { axis: 0, inplace: true })

df.print()
```

{% endtab %}

{% tab title="Browser" %}

```
```

{% endtab %}
{% endtabs %}

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

```
╔════════════╤═══════════════════╤═══════════════════╗
║            │ Col1              │ Col2              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 0                 │ 1                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ 1                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 2          │ 0                 │ 0                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 3          │ 0                 │ 0                 ║
╚════════════╧═══════════════════╧═══════════════════╝

```

{% endtab %}
{% endtabs %}


---

# 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/dataframe/danfo.dataframe.mod.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.
