Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize Multi-dimensional Array assignment after slicing in NumPy

Shulou Source: shulou.com Published: 2022-06-02 05:28:22 10月02日 Update

This article will explain in detail how to achieve multi-dimensional array slice assignment in NumPy. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license ()" for more information. > > import numpy as np > a = np.zeros (3Mague 5)) > aarray ([[0.,0.,0.,0.,0.], [0.,0.0.0.0.0.], [0.,0.,0.]. > > barray ([[1.1,1.1.1.1.1.1.1], [1.1.1.1.1.1.1.1], [1.1.1.1.1.1.1.1]) > > a [: 2] = b [: 2jue:] > > aarray ([[1.1,1.1.1.1.1.1.1], [1.1.1.1.1.1]) > > aarray. 1.], [0, 0, 0, 0, 0.]) > a = np.zeros (3) 5)) > > a [: 2 recorder 3] = b [: 2 recuperation 3] > aarray ([[1, 1, 1, 1, 0, 0.], [1, 1, 1, 0, 0.], [0, 0, 0, 0. 0.]]) > a = np.zeros ((3d5)) > a [:: 2] = b [:: 2] > > aarray ([[1.1,1.1.1.1.1.1.1.], [0.1,0.,0.,0.,0.], [1.1.1.1.1.1.1.1.]) > this is where we share the assignment of multi-dimensional array slices in NumPy. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Array multidimensional content article more knowledge article good quality reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Shulou Tech Info Linux NVidia