0% found this document useful (0 votes)
585 views26 pages

Chapter 2 - NumPy and Pandas

Uploaded by

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

Chapter 2 - NumPy and Pandas

Uploaded by

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

Data Representation

NumPy, Pandas

Chapter - 3
Contents

• List of Libraries/Packages for Data Science


• Numpy Arrays
• Pandas
• Series and Data Frames
• Import/export Data Sets
• Web Scrapping
List of required Packages
• Python libraries for Data Science
Numpy
SciPy
Pandas
Matplotlib
Seaborn
Plotly
Scikit Learn
TensorFlow
Beautiful Soup
What is numpy?
• Numpy(stands for Numerical Python) is a python package
specifically designed for efficiently working
on homogeneous n-dimensional arrays .
• NumPy is very useful for performing mathematical and
logical operations on Arrays.
• NumPy arrays are called ndarray or N-dimensional
arrays and they store elements of the same type and size.
• Various other libraries like Pandas, Matplotlib, and
Scikit-learn are built on top of this amazing library.
• NumPy arrays are up to 50x faster that traditional Python
lists.
How to create a basic array?
NumPy Array

10

20

30
1-dimensional Array

2-dimensional
array

NOTE: NumPy’s array class is called ndarray. It is also known by the alias array
Creating array using arange()
• NumPy arange() creates an
instance of ndarray with
evenly spaced values and
returns the reference to it.

• Syntax

numpy.arange([start, ]stop,
[step, ], )
Python NumPy ndarray
Objects and Operations
ndarray.ndim
• the number of axes (dimensions) of the array.

ndarray.shape
• This is a tuple of integers indicating the size of the
array in each dimension. For a matrix with n rows and
m columns, shape will be (n,m).

ndarray.size
• the total number of elements of the array. This is
equal to the product of the elements of shape.
Python NumPy ndarray Objects
and Operations
ndarray.dtype
• an object describing the type of the elements in the array.
Example types are numpy.int32, numpy.int16, and
numpy.float64 .

ndarray.itemsize
• the size in bytes of each element of the array. For example, an
array of elements of type float64 has itemsize .

ndarray.reshape:
• Reshape is when you change the number of rows and columns
which gives a new view to an object.
• ndarray.reshape(new shape)
Python NumPy ndarray
Objects/Operations...
Array Indexing, Slicing and Filtering
Broadcasting in NumPy Arrays
• Broadcasting is one of the best features of ndarray.
• It allows us to perform arithmetic operations between arrays of same
shape/different sizes or between a single number and an array.
Numpy Functions
Stacking ndarrys
What is Pandas?
• Pandas is a Python library for data analysis.
• It offers a number of data exploration, cleaning and
transformation operations that are critical in working with
data in Python.
• Commonly used data structures in pandas are:
• Series objects: 1D array, similar to a column in a
spreadsheet
• DataFrame objects: 2D table, similar to a spreadsheet
• Panel objects: Dictionary of DataFrames, similar to sheet
in MS Excel
Pandas Series
• Pandas Series is a one-dimensional labeled array capable of holding data of any
type (integer, string, float, python objects, etc.).
• The axis labels are collectively called index.
Pandas Series...
Accessing element of Series
Pandas DataFrame
It’s a 2 D - size-mutable, potentially heterogeneous tabular data
structure (like table) with rows and columns.

https://www.geeksforgeeks.org/python-pandas-
dataframe/
https://www.learndatasci.com/tutorials/python-pandas-tutorial-complete-introduction-for-
beginners/
Creating Dataframes
Dataframe
Rename column
Creation
DataFrame

Column DroppingColumn Addition


Dealing with Columns in a
Appending a
Dataframe Appending
row
Dealing with Rows in a DataFrame

Updating row
Dropping
values
rows
Basic Operation on Dataframes
Subsetting Dataframes
subsetting subsetting subsetting Rows
Rows Columns & Columns
Subsetting Dataframes...
subsetting by
subsetting by label position
Filtering Dataframes
References :
https://numpy.org/devdocs/user/absolute_beginners.html
https://datascience.quantecon.org/scientific/numpy_arrays.html
https://www.geeksforgeeks.org/numpy-stack-in-python/
https://www.machinelearningplus.com/python/101-numpy-exercises-python/
https://realpython.com/pandas-dataframe
/#:~:text=%20The%20Pandas%20DataFrame%3A%20Make%20Working%20With%20Data
,that%20you%E2%80%99ve%20created%20your%20DataFrame%2C%20you...%
20More%20
https://www.geeksforgeeks.org/implementing-web-scraping-python-beautiful-soup/?ref=rp

You might also like