0% found this document useful (0 votes)
28 views3 pages

How Do I Install Numpy?: Numpy Array: Numpy Array Is A Powerful N-Dimensional Array Object Which Is in The Form of Rows

NumPy is a Python package for scientific computing that provides powerful n-dimensional arrays and tools for numerical computing. NumPy arrays can store multi-dimensional data and are initialized from nested lists. NumPy allows efficient operations on arrays through functions like linear algebra and random number generation. NumPy arrays can be indexed with other arrays, where each value in the index array indicates which value to use from the original array. This enables complex multi-dimensional indexing of arrays.

Uploaded by

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

How Do I Install Numpy?: Numpy Array: Numpy Array Is A Powerful N-Dimensional Array Object Which Is in The Form of Rows

NumPy is a Python package for scientific computing that provides powerful n-dimensional arrays and tools for numerical computing. NumPy arrays can store multi-dimensional data and are initialized from nested lists. NumPy allows efficient operations on arrays through functions like linear algebra and random number generation. NumPy arrays can be indexed with other arrays, where each value in the index array indicates which value to use from the original array. This enables complex multi-dimensional indexing of arrays.

Uploaded by

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

NumPy is a Python package which stands for ‘Numerical Python’.

It is the core library for scientific


computing, which contains a powerful n-dimensional array object, provide tools for integrating
C, C++ etc. It is also useful in linear algebra, random number capability etc. NumPy array can also
be used as an efficient multi-dimensional container for generic data. Now, let me tell you what
exactly is a python numpy array.

NumPy Array: Numpy array is a powerful N-dimensional array object which is in the form of rows
and columns. We can initialize numpy arrays from nested Python lists and access it elements. In
order to perform these numpy operations, the next question which will come in your mind is:

How do I install NumPy?

To install Python NumPy, go to your command prompt and type “pip install numpy”. Once the
installation is completed, go to your IDE (For example: PyCharm) and simply import it by typing:
“import numpy as np”

Moving ahead in python numpy tutorial, let us understand what exactly is a multi-dimensional
numPy array.

Here, I have different elements that are stored in their respective memory locations. It is said to
be two dimensional because it has rows as well as columns. In the above image, we have 3
columns and 4 rows available.

Single-dimensional Numpy Array:

1import numpy as np
2a=np.array([1,2,3])
3print(a)

Output – [1 2 3]

Multi-dimensional Array:

1a=np.array([(1,2,3),(4,5,6)])
2print(a)

O/P – [[ 1 2 3]
[4 5 6]]
NumPy arrays may be indexed with other arrays (or any other sequence- like object that can be
converted to an array, such as lists, with the exception of tuples; see the end of this document
for why this is). The use of index arrays ranges from simple, straightforward cases to complex,
hard-to-understand cases. For all cases of index arrays, what is returned is a copy of the original
data, not a view as one gets for slices.

Index arrays must be of integer type. Each value in the array indicates which value in the array
to use in place of the index. To illustrate:

>>>
>>> x = np.arange(10,1,-1)
>>> x
array([10, 9, 8, 7, 6, 5, 4, 3, 2])
>>> x[np.array([3, 3, 1, 8])]
array([7, 7, 9, 2])

The index array consisting of the values 3, 3, 1 and 8 correspondingly create an array of length 4
(same as the index array) where each index is replaced by the value the index array has in the
array being indexed.

Negative values are permitted and work as they do with single indices or slices:

>>>
>>> x[np.array([3,3,-3,8])]
array([7, 7, 4, 2])

It is an error to have index values out of bounds:

>>>
>>> x[np.array([3, 3, 20, 8])]
<type 'exceptions.IndexError'>: index 20 out of bounds 0<=index<9

Generally speaking, what is returned when index arrays are used is an array with the same
shape as the index array, but with the type and values of the array being indexed. As an
example, we can use a multidimensional index array instead:

>>>
>>> x[np.array([[1,1],[2,3]])]
array([[9, 9],
[8, 7]])
IndexinginPandas :
Indexing in pandas means simply selecting particular rows and columns of data from a DataFrame.
Indexing could mean selecting all the rows and some of the columns, some of the rows and all of the
columns, or some of each of the rows and columns. Indexing can also be known as Subset Selection

Indexing and Selecting Data


The axis labeling information in pandas objects serves many purposes:

 Identifies data (i.e. provides metadata) using known indicators, important for for analysis,
visualization, and interactive console display
 Enables automatic and explicit data alignment
 Allows intuitive getting and setting of subsets of the data set

In this section, we will focus on the final point: namely, how to slice, dice, and generally get and
set subsets of pandas objects. The primary focus will be on Series and DataFrame as they have
received more development attention in this area. Expect more work to be invested higher-
dimensional data structures (including Panel) in the future, especially in label-based advanced
indexing.

You might also like