- Python Data Analysis(Second Edition)
- Armando Fandango
- 142字
- 2021-07-09 19:04:04
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 it, as demonstrated in the following code snippets:
- Create a multidimensional array as follows:
In: m = np.array([np.arange(2), np.arange(2)]) In: m Out: array([[0, 1], [0, 1]])
- We can show the array shape as follows:
In: m.shape Out: (2, 2)
We made a 2x2 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.
推薦閱讀
- Flutter開發(fā)實戰(zhàn)詳解
- Building a Game with Unity and Blender
- Rake Task Management Essentials
- PostgreSQL技術內(nèi)幕:事務處理深度探索
- OpenCV for Secret Agents
- 數(shù)據(jù)結構簡明教程(第2版)微課版
- Python 3網(wǎng)絡爬蟲實戰(zhàn)
- 深入淺出RxJS
- MongoDB權威指南(第3版)
- Learning Hunk
- bbPress Complete
- Mastering Android Development with Kotlin
- Apache Spark 2.x for Java Developers
- Swift Playgrounds少兒趣編程
- 深度學習:Java語言實現(xiàn)