Home  >  Article  >  Backend Development  >  Example of adding a row or column to a python matrix_python

Example of adding a row or column to a python matrix_python

不言
不言Original
2018-04-04 16:35:037954browse

Below I will share with you an example of adding a row or column to a Python matrix. It has a good reference value and I hope it will be helpful to everyone. Let’s take a look together

Add rows to the matrix

np.row_stack() 与 np.column_stack()
import numpy as np
a = np.array([[4, 4,], [5, 5]])
c = np.row_stack((a, [8,9]))
d = np.column_stack((a, [8,9]))

Related recommendations:

Distance measurement and python implementation

Python implementation of two-dimensional array output as picture_python

The above is the detailed content of Example of adding a row or column to a python matrix_python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn