Numpy ndarrays are n-dimensional, homogeneous arrays that provide an efficient way to store and manipulate large multi-dimensional datasets. They are the fundamental data structure in NumPy that enables working with homogeneous data. An ndarray is created with a shape that defines its dimensions and a data type that specifies the type of data elements. It supports common operations like arithmetic, indexing/slicing, aggregation, reshaping and transposing. NumPy ndarrays are an essential tool for numerical computing and data analysis in Python.
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...HendraPurnama31
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkualitas publikasi dalam berbagai format cetak dan lingkungan interaktif di berbagai platform.
Abstract: This PDSG workshop introduces the basics of Python libraries used in machine learning. Libraries covered are Numpy, Pandas and MathlibPlot.
Level: Fundamental
Requirements: One should have some knowledge of programming and some statistics.
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...HendraPurnama31
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkualitas publikasi dalam berbagai format cetak dan lingkungan interaktif di berbagai platform.
Abstract: This PDSG workshop introduces the basics of Python libraries used in machine learning. Libraries covered are Numpy, Pandas and MathlibPlot.
Level: Fundamental
Requirements: One should have some knowledge of programming and some statistics.
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
The actual illustration of values is decided by the machine design (.pdfanyacarpets
The actual illustration of values is decided by the machine design (strictly speaking, by the C
implementation). the particular size is accessed through the itemsize attribute. The values hold
on for \'L\' and \'I\' things are diagrammatical as Python long integers once retrieved, as a result
of Python’s plain number sort cannot represent the complete vary of C’s unsigned (long)
integers.
The module defines the subsequent type:
class array.array(typecode[, initializer])
A new array whose things ar restricted by typecode, and initialized from the nonmandatory
initializer worth, that should be a listing, string, or iterable over components of the acceptable
sort.
Changed in version two.4: at one time, solely lists or strings were accepted.
If given a listing or string, the initializer is passed to the new array’s fromlist(), fromstring(), or
fromunicode() methodology (see below) to feature initial things to the array. Otherwise, the
iterable initializer is passed to the extend() methodology.
array.ArrayType
Obsolete alias for array.
Array objects support the normal sequence operations of assortment, slicing, concatenation, and
multiplication. once mistreatment slice assignment, the assigned worth should be Associate in
Nursing array object with an equivalent sort code; all told alternative cases, TypeError is raised.
Array objects additionally implement the buffer interface, and should be used where buffer
objects ar supported.
The following information things and ways also are supported:
array.typecode
The typecode character wont to produce the array.
array.itemsize
The length in bytes of 1 array item within the representation.
array.append(x)
Append a replacement item with worth x to the tip of the array.
array.buffer_info()
Return a tuple (address, length) giving the present memory address and also the length in
components of the buffer wont to hold array’s contents. the dimensions of the memory buffer in
bytes is computed as array.buffer_info()[1] * array.itemsize. this can be often helpful once
operating with low-level (and inherently unsafe) I/O interfaces that need memory addresses, like
bound ioctl() operations. The came back numbers ar valid as long because the array exists and no
length-changing operations ar applied thereto.
Note once mistreatment array objects from code written in C or C++ (the solely thanks to
effectively create use of this information), it makes a lot of sense to use the buffer interface
supported by array objects. This methodology is maintained for backward compatibility and may
be avoided in new code. The buffer interface is documented in Buffers and Memoryview
Objects.
array.byteswap()
“Byteswap” all things of the array. this can be solely supported for values that ar one, 2, 4, or
eight bytes in size; for alternative sorts of values, RuntimeError is raised. it\'s helpful once
reading information from a file written on a machine with a unique computer memory unit order.
array.count(x)
Return the amount of occur.
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
The actual illustration of values is decided by the machine design (.pdfanyacarpets
The actual illustration of values is decided by the machine design (strictly speaking, by the C
implementation). the particular size is accessed through the itemsize attribute. The values hold
on for \'L\' and \'I\' things are diagrammatical as Python long integers once retrieved, as a result
of Python’s plain number sort cannot represent the complete vary of C’s unsigned (long)
integers.
The module defines the subsequent type:
class array.array(typecode[, initializer])
A new array whose things ar restricted by typecode, and initialized from the nonmandatory
initializer worth, that should be a listing, string, or iterable over components of the acceptable
sort.
Changed in version two.4: at one time, solely lists or strings were accepted.
If given a listing or string, the initializer is passed to the new array’s fromlist(), fromstring(), or
fromunicode() methodology (see below) to feature initial things to the array. Otherwise, the
iterable initializer is passed to the extend() methodology.
array.ArrayType
Obsolete alias for array.
Array objects support the normal sequence operations of assortment, slicing, concatenation, and
multiplication. once mistreatment slice assignment, the assigned worth should be Associate in
Nursing array object with an equivalent sort code; all told alternative cases, TypeError is raised.
Array objects additionally implement the buffer interface, and should be used where buffer
objects ar supported.
The following information things and ways also are supported:
array.typecode
The typecode character wont to produce the array.
array.itemsize
The length in bytes of 1 array item within the representation.
array.append(x)
Append a replacement item with worth x to the tip of the array.
array.buffer_info()
Return a tuple (address, length) giving the present memory address and also the length in
components of the buffer wont to hold array’s contents. the dimensions of the memory buffer in
bytes is computed as array.buffer_info()[1] * array.itemsize. this can be often helpful once
operating with low-level (and inherently unsafe) I/O interfaces that need memory addresses, like
bound ioctl() operations. The came back numbers ar valid as long because the array exists and no
length-changing operations ar applied thereto.
Note once mistreatment array objects from code written in C or C++ (the solely thanks to
effectively create use of this information), it makes a lot of sense to use the buffer interface
supported by array objects. This methodology is maintained for backward compatibility and may
be avoided in new code. The buffer interface is documented in Buffers and Memoryview
Objects.
array.byteswap()
“Byteswap” all things of the array. this can be solely supported for values that ar one, 2, 4, or
eight bytes in size; for alternative sorts of values, RuntimeError is raised. it\'s helpful once
reading information from a file written on a machine with a unique computer memory unit order.
array.count(x)
Return the amount of occur.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Numpy ndarrays.pdf
1. Numpy ndarrays
One of the fundamental components of NumPy is the ndarray (short for
“n-dimensional array”). The ndarray is a versatile data structure that enables
you to work with homogeneous, multi-dimensional data. In this guide, we’ll
dive deep into understanding ndarray, its structure, attributes, and
operations.
Introduction to ndarrays
An ndarray is a multi-dimensional, homogeneous array of elements, all of the
same data type. It provides a convenient way to store and manipulate large
datasets, such as images, audio, and scientific data. ndarrays are the lynchpin
of many scientific and data analysis libraries in Python.
Creating ndarrays
Follow TechVidvan on Google & Stay updated with latest
technology trends
Using numpy.array()
The numpy.array() function allows you to create an ndarray from an existing
list or iterable.
import numpy as np
data_list = [1, 2, 3, 4, 5]
arr = np.array(data_list)
2. Using numpy.zeros() and numpy.ones()
You can create arrays filled with zeros or ones using these functions.
zeros_arr = np.zeros((3, 4)) # Creates a 3x4 array of zeros
ones_arr = np.ones((2, 2)) # Creates a 2x2 array of ones
Using numpy.arange() and numpy.linspace()
numpy.arange() generates an array with evenly spaced values within a
specified range, while numpy.linspace() generates an array with a specified
number of evenly spaced values between a start and end.
range_arr = np.arange(0, 10, 2) # Array from 0 to 10 with
step 2
linspace_arr = np.linspace(0, 1, 5) # Array of 5 values from
0 to 1
Parameters of the ndarray Class
a. shape
The shape parameter is a tuple of integers that defines the dimensions of the
created array. It specifies the size of the array along each axis, making it
possible to create arrays of different shapes, from one-dimensional to
multi-dimensional arrays.
3. b. dtype (data type)
The dtype parameter specifies the data type of the elements within the array.
It can be any object that can be interpreted as a NumPy data type. This allows
you to control the precision and characteristics of the data stored in the array,
whether it’s integers, floating-point numbers, or other custom data types.
c. buffer
The buffer parameter is an optional object that exposes the buffer interface. It
can be used to fill the array with data from an existing buffer. This is useful
when you want to create an ndarray that shares data with another object, such
as a Python bytes object or another ndarray.
d. offset
The offset parameter is an integer that specifies the offset of the array data
within the buffer (if the buffer parameter is provided). It allows you to start
filling the array from a particular position within the buffer, which can be
useful for creating views or sub-arrays.
e. Strides
The strides parameter is an optional tuple of integers that defines the strides
of data in memory. Strides determine the number of bytes to move in memory
to access the next element along each axis. This parameter can be used to
create arrays with non-contiguous data layouts, enabling efficient operations
on sub-arrays or views.
f. order
4. The order parameter specifies the memory layout order of the array. It can
take two values: ‘C’ for row-major (C-style) order and ‘F’ for column-major
(Fortran-style) order. The memory layout affects how the elements are stored
in memory, and it can influence the efficiency of accessing elements in
different patterns.
Attributes of the ndarray Class
a. T (Transpose)
The T attribute returns a view of the transposed array. This operation flips the
dimensions of the array, effectively swapping rows and columns. It is
especially useful for linear algebra operations and matrix manipulations.
b. data (Buffer)
The data attribute is a Python buffer object that points to the start of the
array’s data. It provides a direct interface to the underlying memory of the
array, allowing for seamless interaction with other libraries or Python’s
memory buffers.
c. dtype (Data Type)
The dtype attribute returns a dtype object that describes the data type of the
array’s elements. It provides information about the precision, size, and
interpretation of the data, whether it’s integers, floating-point numbers, or
custom-defined data types.
d. flags (Memory Layout Information)
5. The flags attribute returns a dictionary containing information about the
memory layout of the array. It includes details like whether the array is
C-contiguous, Fortran-contiguous, or read-only. This information can be
crucial for optimizing array operations.
e. flat (1-D Iterator)
The flat attribute returns a 1-D iterator over the array. This iterator allows you
to efficiently traverse all elements in the array, regardless of their shape. It’s
particularly useful when you want to apply an operation to each element in the
array without the need for explicit loops.
f. imag and real (Imaginary and Real Parts)
The image and real attributes return separate ndarrays representing the
imaginary and real parts of the original array, respectively. This is particularly
relevant for complex numbers, allowing you to manipulate the real and
imaginary components individually.
g. size (Number of Elements)
The size attribute returns an integer indicating the total number of elements in
the array. It’s a convenient way to quickly determine the array’s overall
capacity.
h. item size (Element Size in Bytes)
6. The item size attribute returns an integer representing the size of a single
array element in bytes. This is essential for calculating the total memory
consumption of the array.
i. nbytes (Total Bytes Consumed)
The nbytes attribute is an integer indicating the total number of bytes
consumed by all elements in the array. It’s a comprehensive measure of the
memory usage of the array.
j. ndim (Number of Dimensions)
The ndim attribute returns an integer indicating the number of dimensions in
the array. It defines the array’s rank or order.
k. shape (Array Dimensions)
The shape attribute returns a tuple of integers representing the dimensions of
the array. It defines the size of the array along each axis.
l. strides (Byte Steps)
The strides attribute returns a tuple of integers indicating the number of bytes
to step in each dimension when traversing the array. This information is
crucial for understanding how the array’s data is laid out in memory.
m. ctypes (Interaction with ctypes)
7. The ctypes attribute provides an object that simplifies the interaction of the
array with the ctypes module, which is useful for interoperability with
low-level languages like C.
n. base (Base Array)
The base attribute returns the base array if the memory is derived from some
other object. This is particularly relevant when working with views or arrays
that share memory with other arrays.
Indexing and Slicing
You can access elements within an ndarray using indexing and slicing.
Advertisement
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr[0, 1]) # Output: 2 (element at row 0, column 1)
print(arr[:, 1:3]) # Output: [[2, 3], [5, 6]] (slicing columns
1 and 2)
Array Operations
Element-wise Operations
ndarrays support element-wise operations like addition, subtraction,
multiplication, and division.
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
result = arr1 + arr2 # Element-wise addition
print(result)
8. Output:
[5 7 9]
Broadcasting
Broadcasting allows arrays with different shapes to be combined in
operations.
arr = np.array([[1, 2, 3], [4, 5, 6]])
scalar = 2
result = arr + scalar # Broadcasting scalar to all elements
print(result)
Output:
[[3 4 5]
[6 7 8]]
Reshaping and Transposing
You can reshape and transpose ndarrays to change their dimensions and
orientations.
arr = np.array([[1, 2, 3], [4, 5, 6]])
reshaped_arr = arr.reshape((3, 2)) # Reshaping to 3x2
transposed_arr = arr.T # Transposing the array
print("Original Array:")
print(arr)
print("nReshaped Array (3x2):")
print(reshaped_arr)
10. print("Standard Deviation:", std_dev)
Output:
Array: [1 2 3 4 5]
Mean: 3.0
Median: 3.0
Standard Deviation: 1.4142135623730951
Boolean Indexing and Fancy Indexing
Boolean indexing allows you to select elements
based on conditions.
arr = np.array([10, 20, 30, 40, 50])
mask = arr > 30
result = arr[mask]
Output: [40, 50]
Fancy indexing involves selecting elements using
integer arrays.
arr = np.array([1, 2, 3, 4, 5])
indices = np.array([1, 3])
result = arr[indices]
Output: [2, 4]
Conclusion
11. In this tutorial, we’ve explored the world of ndarrays in NumPy. We’ve
ventured into creating ndarrays, understanding their attributes, performing
various operations, and even touching on advanced indexing techniques. The
ndarray’s versatility and efficiency make it an essential tool for numerical
computations and data analysis in Python. With the knowledge gained here,
you’re well-equipped to start harnessing the power of NumPy ndarrays for
your own projects. Happy coding!