0% found this document useful (0 votes)
2 views

Numpy and Pandas 1737800937

The document presents an overview of NumPy and Pandas, two essential libraries for numerical computing and data analysis in Python. NumPy provides support for multi-dimensional arrays and a variety of mathematical functions, while Pandas offers powerful data structures like DataFrames and Series for data manipulation. Both libraries are crucial for efficient data wrangling and exploration in Python.

Uploaded by

vickynifem
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)
2 views

Numpy and Pandas 1737800937

The document presents an overview of NumPy and Pandas, two essential libraries for numerical computing and data analysis in Python. NumPy provides support for multi-dimensional arrays and a variety of mathematical functions, while Pandas offers powerful data structures like DataFrames and Series for data manipulation. Both libraries are crucial for efficient data wrangling and exploration in Python.

Uploaded by

vickynifem
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/ 26

NUMPY AND

PANDAS
Presented by:

Ridwan Ibidunni

aljebraschool.hashnode.dev Date : 27 - 04 - 24
INTRODUCTION

Numpy Pandas
01 NumPy, short for Numerical Python, is an essential 02 Pandas is a fast, powerful, and flexible open-source
package for numerical computing in Python. It offers library for data analysis and manipulation. Built on
support for large, multi-dimensional arrays and top of NumPy, it provides intuitive data structures,
matrices, as well as a range of mathematical functions high-performance tools, and analysis capabilities,
for efficient array operations. making it essential for data wrangling and
exploration in Python.

aljebraschool.hashnode.dev
NUMPY
NumPy is a fundamental package for numerical computing in Python,
serving as the cornerstone of numerical and scientific computing. Its
primary data structure, ndarray, is a powerful N-dimensional array
object designed for fast and space-efficient data storage and
manipulation. Key features include a wide range of mathematical,
logical, and statistical operations on arrays, seamless integration
with other languages such as C/C++ and Fortran, making it ideal for
numerical computations and data analysis.

aljebraschool.hashnode.dev
NUMPY ARRAY
IMPLEMENTATIONS

aljebraschool.hashnode.dev
CREATING
NUMPY ARRAY

The most basic form of a NumPy array is a one-dimensional


(1-D) array, which can be created using the array() function
with a list as its argument.

aljebraschool.hashnode.dev
CREATING
NUMPY ARRAY

Another method of creating a NumPy array is by using the


arange() function, which is similar to the range() function
used for lists. It takes three arguments: the starting value,
the end value (one less than the specified value), and the
step size for incrementing or decrementing.

aljebraschool.hashnode.dev
CREATING
NUMPY ARRAY

The linspace() function allows us to create an array with a


specified number of elements between a specified range,
including both the starting and ending values. This is different
from the arange() function, as linspace() returns an array with
a specified number of elements evenly spaced within the
specified interval.

aljebraschool.hashnode.dev
NUMPY ARRAYS WITH
FIXED ELEMENTS

NumPy offers specific functions like zeros(), ones(), and full() to


initialize arrays with fixed values. These functions take the
desired size (number of elements) of the array as an
argument.

aljebraschool.hashnode.dev
MULTIDIMENSIONAL
ARRAY

Arrays can also be multidimensional, similar to tables with more


than one row and one column. To create a multidimensional
array, each row of the array is represented as a list, with each
element in the list corresponding to a column. These lists are
then separated by commas. The rows and columns must be
enclosed in outer square brackets as well.

aljebraschool.hashnode.dev
NUMPY ARRAY
DIMENSIONS

The size function is used to determine the number of elements


in an array. The shape function returns the number of rows and
columns in an array, while the ndim function is used to find the
dimensionality (number of dimensions) of an array.

aljebraschool.hashnode.dev
ARRAY MATH
OPERATION

NumPy enables you to perform element-wise addition,


subtraction, multiplication, and division effortlessly on both 1-D
and multidimensional arrays. These operations use standard
mathematical symbols: +, -, and *. Unlike Python lists, where
addition results in concatenation, NumPy operations work
element-wise.

aljebraschool.hashnode.dev
BROADCASTING IN
NUMPY ARRAY

NumPy's broadcasting feature enables it to perform arithmetic


operations on arrays of different shapes. When conducting
element-wise operations like addition, subtraction, and
multiplication on arrays with different shapes, NumPy
automatically broadcasts the arrays to have compatible shapes.
This facilitates element-wise operations without requiring the
arrays to have the same shape. For instance, if you have a 1D
array of shape (3,) and want to add a scalar value to it, NumPy
will automatically broadcast the scalar value to match the
shape of the array (3,), allowing element-wise addition to be
performed seamlessly.

aljebraschool.hashnode.dev
PANDAS
Pandas, built on top of NumPy, is a powerful open-source data
analysis and manipulation library for Python. It offers intuitive data
structures like DataFrame and Series, along with tools for indexing,
slicing, merging, reshaping, and aggregating data. With support for
various file formats including CSV, Excel, SQL databases, and JSON,
Pandas is essential for data wrangling and exploration in Python.

aljebraschool.hashnode.dev
PANDAS
IMPLEMENTATION

aljebraschool.hashnode.dev
CREATING
SERIES

A Series is an enhanced one-dimensional array. It goes


beyond supporting zero-based indices; it also allows for
custom indexing, including non-integer indices such as
strings.

aljebraschool.hashnode.dev
CREATING
SERIES

The Series provides many methods for common descriptive


statistical tasks, including count, mean, min, max, std
(standard deviation), and more.

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

A DataFrame is an enhanced two-dimensional array. Like


Series, DataFrames can have custom row and column
indices, along with additional operations and capabilities
that make them more convenient for many data science-
related tasks.

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

In Pandas, you can access each column by specifying the


column name inside square brackets after the DataFrame
name, as shown in this image

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

According to the Pandas documentation, using [] to access


DataFrame items is not the most optimized approach, as it
creates a copy of the data, which can lead to logical errors
when assigning new values. Instead, it's recommended to
use the loc and iloc attributes for accessing DataFrame
items. You can access a row by its label using the loc
attribute or by its index using the iloc attribute.

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

Slicing can be used to obtain a portion of the table. Some of


these are implemented in this image

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

More examples on Slicing

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

More examples on Slicing

aljebraschool.hashnode.dev
CREATING
DATAFRAMES

Finally, you can obtain a quick summary of its main


descriptive statistics using the describe() function using the
same dataset from the previous slides, as shown in this
image

aljebraschool.hashnode.dev
MACHINE LEARNING REPO
github.com/aljebraschool
To stay updated with my
work, visit my website.

aljebraschool.github.io
ALJEBRASCHOOL

ALJEBRA SCHOOL TWITTER LINKEDIN FACEBOOK


BLOG

aljebraschool.hashnode.dev twitter.com/aljebraschool linkedin.com/in/aljebraschool facebook.com/aljebraschool

LINK UP
Follow us on all social media for more updates!!!

...ideas rule the world...

You might also like