0% found this document useful (0 votes)
4 views14 pages

MLS2 Python For Data Science NumPy and Pandas

The document provides an overview of Python for Data Science, including common libraries such as NumPy and Pandas, along with their functions and applications. It also covers the differences between merging and joining dataframes in Pandas. Additionally, it includes a pop quiz to test knowledge on the material presented.

Uploaded by

jeevankumar86
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)
4 views14 pages

MLS2 Python For Data Science NumPy and Pandas

The document provides an overview of Python for Data Science, including common libraries such as NumPy and Pandas, along with their functions and applications. It also covers the differences between merging and joining dataframes in Pandas. Additionally, it includes a pop quiz to test knowledge on the material presented.

Uploaded by

jeevankumar86
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

Python for Data Science

jeevankumar86@[Link]
HW5L9XFNBU

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Agenda

1. Pop Quiz
2. Common Python Libraries for Data Science
3. NumPy and Pandas
4. Common NumPy functions
5. Common Pandas functions
jeevankumar86@[Link]
6. Merge vs Join
HW5L9XFNBU in Pandas
7. Example of Join

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Pop Quiz

1. What are the data types in Python?


2. What are some of the common Python libraries for Data Science?
3. Can you list some of the common functions in Pandas?
4. What are the applications of the functions like group by, merge, join etc?

jeevankumar86@[Link]
HW5L9XFNBU

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited. 3
Common Python Libraries for Data Science

Library Use

NumPy Handling multi-dimensional arrays

Scipy Scientific computation package

Matplotlib, Seaborn Data visualisation


jeevankumar86@[Link]
HW5L9XFNBU
Pandas Handling tabular data

Scikit-learn Machine learning

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
NumPy

● Stands for Numerical Python


● It is one of the fundamental packages for mathematical, logical, and statistical operations with
Python
● It contains
○ Powerful N-dimensional array object, called ndarray
jeevankumar86@[Link]
HW5L9XFNBU ○ Large set of functions for creating, manipulating, and transforming ndarrays
● ndarrays can only contain data of a single datatype
● Useful in linear algebra, vector calculus, random number capabilities, etc

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Pandas

● Pandas is one of the fundamental packages for analysis and manipulation of tabular data
● Offers two major data structures - series & dataframe
● We can think of a pandas dataframe like an excel spreadsheet that is storing some data in rows and
columns.
● A pandas dataframe is made up of several pandas series
jeevankumar86@[Link]
HW5L9XFNBU ○ Each column of a dataframe is a series.
● Pandas dataframes can contain data of multiple datatypes

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Common NumPy Functions

Function Description

[Link]() To create an array

[Link]() Return evenly spaced values within a given interval

[Link]() Return evenly spaced numbers over a specified interval


jeevankumar86@[Link]
HW5L9XFNBU
[Link]() To create an array of zeros

[Link]() To create an array of ones

[Link]() Permute array dimensions

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Common NumPy Functions

Function Description

[Link]() To create an array of specified shape filled with random values

[Link]() Return random integers from low (inclusive) to high (exclusive)

[Link]() Return a sample (or samples) from the “standard normal” distribution.
jeevankumar86@[Link]
[Link]()
HW5L9XFNBU
Concatenate two arrays

[Link]() Save an array to a binary file in .npy format.

[Link]() Save several arrays into a single file in uncompressed .npz format.

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Common Pandas Functions

Function Description

pd.read_csv() Read a comma-separated values (csv) file into DataFrame

[Link][] Access a group of rows and columns by label(s)

[Link][] Purely integer-location based indexing for selection by position


jeevankumar86@[Link]
HW5L9XFNBU
[Link]() Drop specified labels from rows or columns

[Link]() To concatenate two pandas objects

[Link]() To merge the pandas dataframes

[Link]() To split, apply or combine the data structures

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Common Pandas Functions

Function Description

df.value_counts() To get count of some attributes

[Link]() To get unique values

[Link] To get the data types


jeevankumar86@[Link]
HW5L9XFNBU
[Link] To get the shape (number or rows and columns)

[Link]() To get the top rows

[Link]() To get the last rows

[Link]() To get the quick statistic summary

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Merge vs Join

• Join: The join method works best when we are joining dataframes on their indexes (though you
can specify another column to join on for the left dataframe).
• Merge: The merge method is more versatile and allows us to specify columns besides the index
to join on for both dataframes.

Natural join - Full outer join -


Left outer join Right outer join
Intersection Union
jeevankumar86@[Link]
HW5L9XFNBU To keep onlyrows To keep all rows from To include all the To include all the
that match from the both data frames, rows of your data rows of your data
data frames frame x and only frame y and only
those from y that those from x that
match match,
how=‘inner’. how=‘outer’. how =‘left’. how=‘right’.

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Example of Join

jeevankumar86@[Link]
HW5L9XFNBU

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Example of Join

jeevankumar86@[Link]
HW5L9XFNBU

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Happy Learning !
jeevankumar86@[Link]
HW5L9XFNBU

This file is meant for personal use by jeevankumar86@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action. 14
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.

You might also like