Question #6484
Submitted by

**Answiki**on 08/25/2022 at 07:24:02 PM UTC# How to subtract two arrays in Python?

Merged questions

Answer
Submitted by

**Answiki**on 08/25/2022 at 07:25:16 PM UTCThe best way to subtract two arrays (`np.array`

) in Python is to use the `np.subtract()`

method. Here is an example:

```
import numpy as np
A = np.array([1, 2, 3, 4])
B = np.array([1, 4, 2, 8])
# Subtraction: R = A - B
R = np.subtract(A, B)
# R = [0 -2 1 -4]
print(R)
```

Answer by

**Answiki**on 08/25/2022 at 07:25:16 PMThe best way to subtract two arrays (`np.array`

) in Python is to use the `np.subtract()`

method. Here is an example:

```
import numpy as np
A = np.array([1, 2, 3, 4])
B = np.array([1, 4, 2, 8])
# Subtraction: R = A - B
R = np.subtract(A, B)
# R = [0 -2 1 -4]
print(R)
```

Question by

**Answiki**08/25/2022 at 07:24:45 PM
How to subtract arrays in Python?

Answer by

**Answiki**on 08/25/2022 at 07:24:35 PMThe best way to subtract two arrays (`np.array`

) in Python is to use the `np.subtract()`

method. Here is an example:

```
import numpy as np
A = np.array([1, 2, 3, 4])
B = np.array([1, 4, 2, 8])
# Subtraction : R = A - B
R = np.subtract(A, B)
# R = [0 -2 1 -4]
print(R)
```

Question by

**Answiki**08/25/2022 at 07:24:02 PM
How to subtract two arrays in Python?

# | ID | Query | URL | Count |
---|

Icons proudly provided by Friconix.