0% found this document useful (0 votes)
46 views2 pages

1.a Numpy Code

The document introduces NumPy, a Python library that provides efficient operations for manipulating large multi-dimensional arrays and matrices. It shows how NumPy can be used to create arrays from scratch or from existing Python lists, and demonstrates various array properties and operations like shape, size, indexing, slicing, and reshaping arrays into different dimensions.

Uploaded by

venkatesh m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

1.a Numpy Code

The document introduces NumPy, a Python library that provides efficient operations for manipulating large multi-dimensional arrays and matrices. It shows how NumPy can be used to create arrays from scratch or from existing Python lists, and demonstrates various array properties and operations like shape, size, indexing, slicing, and reshaping arrays into different dimensions.

Uploaded by

venkatesh m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1/20/22, 9:58 PM 1.

a Numpy Code

In [3]:
## Numpy ( numerical for Python)

# It will provide more efficent storage and Data operation as size grows

#NumPy’s main object is the homogeneous multidimensional array.

import numpy as np

In [4]:
a = np.arange(15)

In [5]:
a

Out[5]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

In [7]:
a.reshape(3,5)

Out[7]: array([[ 0, 1, 2, 3, 4],

[ 5, 6, 7, 8, 9],

[10, 11, 12, 13, 14]])

In [8]:
a.ndim

Out[8]: 1

In [9]:
a.dtype.name

Out[9]: 'int32'

In [10]:
a

Out[10]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

In [11]:
a.size

Out[11]: 15

In [12]:
a[1:3]

Out[12]: array([1, 2])

In [13]:
a[4:]

Out[13]: array([ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

In [14]:
a[4]

Out[14]: 4

file:///C:/Users/rgandyala/Downloads/1.a Numpy Code.html 1/2


1/20/22, 9:58 PM 1.a Numpy Code

In [13]:
a[8]

Out[13]: 8

In [9]:
# Reverse the order of array

a[::-2]

Out[9]: array([14, 12, 10, 8, 6, 4, 2, 0])

In [12]:
x = a.reshape(3,5)

Out[12]: array([[ 0, 1, 2, 3, 4],

[ 5, 6, 7, 8, 9],

[10, 11, 12, 13, 14]])

In [14]:
x[2]

Out[14]: array([10, 11, 12, 13, 14])

In [19]:
# two rows and three columns

x[:2, :3]

Out[19]: array([[0, 1, 2],

[5, 6, 7]])

In [20]:
# three rows and two colums

x[:3, :2]

Out[20]: array([[ 0, 1],

[ 5, 6],

[10, 11]])

file:///C:/Users/rgandyala/Downloads/1.a Numpy Code.html 2/2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy