Sideway
output.to from Sideway
Draft for Information Only

Content

Return a view of element of a ndarray
 Examples of Return Element of a (3,) ndarray
 Examples of Return Element of a (2, 3) ndarray
 Examples of Return Element of a (3, 3, 3) ndarray
 Sources and References

Return a view of element of a ndarray

Examples of Return Element of a (3,) ndarray

Return Element of a (3,) ndarray
Python Code Input:
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AM
D64)] on win32
>>> import numpy as np
>>> a=np.array([0,1,2])
>>> a
array([0, 1, 2])
>>> a.shape
(3,)
>>> a[0]
0
>>> a[1]
1
>>> a[0],a[1]
(0, 1)
>>> a[0:0]
array([], dtype=int32)
>>> a[0:1]
array([0])
>>> a[1:2]
array([1])
>>> a[0:2]
array([0, 1])
>>> a[0::2]
array([0, 2])
>>> 

Examples of Return Element of a (2, 3) ndarray

Return Element of a (2, 3) ndarray
Python Code Input:
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AM
D64)] on win32
>>> import numpy as np
>>> a=np.array([[0,1,2],[3,4,5]])
>>> a
array([[0, 1, 2],
       [3, 4, 5]])
>>> a.shape
(2, 3)
>>> a[0]
array([0, 1, 2])
>>> a[1]
array([3, 4, 5])
>>> a[0][0]
0
>>> a[0][1]
1
>>> a[0,0]
0
>>> a[1,1]
4
>>> a[0,0:1]
array([0])
>>> a[1,1:2]
array([4])
>>> a[:,0]
array([0, 3])
>>> a[:,1]
array([1, 4])
>>> a[:,1:2]
array([[1]
       [4]])
>>> a[:1,1:]
array([[1, 2]])
>>> a[1:,1:]
array([[4, 5]])
>>> a[1:,:-1]
array([[3, 4]])
>>> a[:1,:-1]
array([[0, 1]])
>>> a[:,1:]
array([[1, 2],
       [4, 5]])
>>> a[:,:-1]
array([[0, 1],
       [3, 4]])
>>> a[:,:]
array([[0, 1, 2],
       [3, 4, 5]])
>>> 

Examples of Return Element of a (3, 3, 3) ndarray

Return Element of a (3, 3, 3) ndarray
Python Code Input:
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AM
D64)] on win32
>>> import numpy as np
>>> a=np.array([[[0,1,2],[3,4,5],[6,7,8]],
...             [[10,11,12],[13,14,15],[16,17,18]],
...             [[20,21,22],[23,24,25],[26,27,28]]])
>>> a
array([[[ 0,  1,  2],
        [ 3,  4,  5],
        [ 6,  7,  8]],

       [[10, 11, 12],
        [13, 14, 15],
        [16, 17, 18]],

       [[20, 21, 22],
        [23, 24, 25],
        [26, 27, 28]]])
>>> a.shape
(3, 3, 3)
>>> a[0]
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
>>> a[0][0]
array([0, 1, 2])
>>> a[0][0][0]
0
>>> a[0,0,0]
0
>>> a[0,0,0:1]
array([0])
>>> a[0,0,0::2]
array([0, 2])
>>> a[0,0,:]
array([0, 1, 2])
>>> a[0,0]
array([0, 1, 2])
>>> a[0,:,:]
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
>>> a[0,:-1,:-1]
array([[0, 1],
       [3, 4]])
>>> a[0,1:,1:]
array([[4, 5],
       [7, 8]])
>>> a[:,1:,1:]
array([[[ 4,  5],
        [ 7,  8]],

       [[14, 15],
        [17, 18]],

       [[24, 25],
        [27, 28]]])
>>> a[:,1:,:]
array([[[ 3,  4,  5],
        [ 6,  7,  8]],

       [[13, 14, 15],
        [16, 17, 18]],

       [[23, 24, 25],
        [26, 27, 28]]])
>>> a[:,1:2,:]
array([[[ 3,  4,  5]],

       [[13, 14, 15]],

       [[23, 24, 25]]])
>>> 

Sources and References

https://stackoverflow.com/questions/952914/how-to-make-a-flat-list-out-of-a-list-of-lists

©sideway

ID: 220100013 Last Updated: 1/13/2022 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79new

Computer

Hardware 224new

Software

Application 213

Digitization 32

Latex 52new

Manim 204

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 33new

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2022 Sideway . All rights reserved Disclaimers last modified on 06 September 2019