- Python Data Analysis(Second Edition)
- Armando Fandango
- 118字
- 2021-07-09 19:04:05
One-dimensional slicing and indexing
Slicing of one-dimensional NumPy arrays works just like the slicing of standard Python lists. Let's define an array containing the numbers 0, 1, 2, and so on up to and including 8. We can select a part of the array from indexes 3 to 7, which extracts the elements of the arrays 3 through 6:
In: a = np.arange(9) In: a[3:7] Out: array([3, 4, 5, 6])
We can choose elements from an index of 0 to 7 with an increment of 2:
In: a[:7:2] Out: array([0, 2, 4, 6])
Just as in Python, we can use negative indices and reverse the array:
In: a[::-1] Out: array([8, 7, 6, 5, 4, 3, 2, 1, 0])
推薦閱讀
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- R語言數據分析從入門到精通
- Mastering JavaScript Object-Oriented Programming
- 移動UI設計(微課版)
- JavaScript高效圖形編程
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- Hands-On Natural Language Processing with Python
- Serverless computing in Azure with .NET
- 新一代SDN:VMware NSX 網絡原理與實踐
- Procedural Content Generation for C++ Game Development
- Learning AngularJS for .NET Developers
- Mastering AWS Security
- UML2面向對象分析與設計(第2版)
- LabVIEW數據采集
- Getting Started with Windows Server Security