- Python Data Analysis
- Ivan Idris
- 150字
- 2021-08-05 17:31:50
Creating a multidimensional array
Now that we know how to create a vector, we are set to create a multidimensional NumPy array. After we produce the matrix, we will again need to show its shape (check arrayattributes.py
from this book's code bundle), as demonstrated in the following code snippets:
- Create a multidimensional array as follows:
In: m = array([arange(2), arange(2)]) In: m Out: array([[0, 1], [0, 1]])
- Show the array shape as follows:
In: m.shape Out: (2, 2)
We made a 2 x 2 array with the arange()
subroutine. The array()
function creates an array from an object that you pass to it. The object has to be an array, for example, a Python list. In the previous example, we passed a list of arrays. The object is the only required parameter of the array()
function. NumPy functions tend to have a heap of optional arguments with predefined default options.
推薦閱讀
- 繪制進程圖:可視化D++語言(第1冊)
- Unreal Engine:Game Development from A to Z
- Mastering Proxmox(Third Edition)
- 機器人編程實戰
- 觸控顯示技術
- 網絡化分布式系統預測控制
- 基于32位ColdFire構建嵌入式系統
- 信息物理系統(CPS)測試與評價技術
- Salesforce Advanced Administrator Certification Guide
- Hands-On Dashboard Development with QlikView
- Photoshop CS4數碼攝影處理50例
- Python文本分析
- MongoDB 4 Quick Start Guide
- 單片機C51應用技術
- Spark Streaming實時流式大數據處理實戰