0% found this document useful (0 votes)
30 views37 pages

Packages

The document discusses Python libraries and packages. It provides an overview of popular Python libraries like NumPy and Pandas. NumPy is introduced as a powerful library for numerical computing and linear algebra. Pandas is described as a library used for data analysis and manipulation. Key data structures in Pandas like Series and DataFrame are also summarized.

Uploaded by

Durga Devi P
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)
30 views37 pages

Packages

The document discusses Python libraries and packages. It provides an overview of popular Python libraries like NumPy and Pandas. NumPy is introduced as a powerful library for numerical computing and linear algebra. Pandas is described as a library used for data analysis and manipulation. Key data structures in Pandas like Series and DataFrame are also summarized.

Uploaded by

Durga Devi P
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/ 37

 Python Libraries

 Introduction
 Installation of Python Library
 Numpy
 Pandas

2
 Python is popular since it has a huge collection of libraries.

 Python libraries are used to create applications and models in a


variety of fields, for instance, machine learning, data science,
data visualization, image and data manipulation.

 Each Python library serve a purpose and contains


collection of codes or modules of codes that can be used in a
program for specific operations. 3
 A Python library is a collection of related modules.
 It contains bundles of code that can be used repeatedly in
different programs.
 It makes Python Programming simpler and convenient for the
programmer.
 As we don’t need to write the same code again and again for
different programs.
4
5
 INSTALLING VIA PIP
• To use the Python library ,first we need to
download and Install it.
• Python comes with an inbuilt package
management system, pip.
• Pip can install, update, or delete
any official package or library.
• You can install packages via the command
line by entering:
 >pip install package_name
 >pip install pandas

6
• NumPy, which stands for Numerical Short brief about Numpy:
Python, is a library consisting of
multidimensional array objects and a
• Author- Travis Oliphant
collection of functions for processing •First Release- 1995 (Released
those arrays. as Numeric; Changed to NumPy in
• NumPy is a powerful linear algebra library 2006)
for Python. • Stable Release- June, 2018
• Using NumPy, mathematical and logical • Written in- Python Programming, C
operations on arrays can be performed.

7
Why NumPy?
• In Python we have lists that serve the purpose of arrays, but
they are slow to process.

• NumPy aims to provide an array object that is up to 50x faster


than traditional Python lists.

• The array object in NumPy is called ndarray, it provides a lot


of supporting functions that make working with ndarray very
easy.

• Arrays are very frequently used in data science, where speed


and resources are very important.
• Multidimensional arrays.
• Functions and operators for these arrays.
• Python Alternative to MATLAB.
• Fourier transforms and shapes manipulation.
• Linear algebra and random number
generation.
9
To b e done in
Command
Line

To b e done while
using numpy in
prog rams 8
Creating NumPy Arrays from Objects
• The most important features
of numpy is ndarray an n-
dimensional array, it is a grid
of values of the same kind.
• There are various ways to
create Numpy Arrays.

9
Create the following NumPy array ?

array([[1, 2, 3],
[3, 4, 5]])
Creating NumPy Arrays from Objects

1
0
11
shape attribute:The shape property of a ndarray is used to get the current shape(row
and column values in case of a matrix or 2-d array) of a given ndarray.
ndim attribute:The ndim property of a ndarray is used to get the dimensions of a
given ndarray.
itemsize attribute:The itemsize attribute is a ndarray attribute that returns the size of each item
in a ndarray in bytes. As an array contains elements of the same data type, the size of each
element in the memory block is also the same.
size attribute:The size property of a ndarray is used to get the no of elements of a given
ndarray.

12
13
To access elements from 2-D arrays we can use
comma separated integers representing the
dimension and the index of the element.

14
Slicing ID Array is similar to the slicing we
did with list,strings etc..
Slicing 2-D Arrays:
Example:
To slice the second element, slice elements
from index 0 to index 1

15
Reshaping means changing the shape of an array.

The shape of an array is the number of elements


in each dimension.

By reshaping we can add or remove dimensions


or change number of elements in each
dimension.

16
Where() method is used for searching an element in an array. It returns the index where the element
is present.

17
The NumPy ndarray object has a function called sort(), that will sort a specified
array.

18
• Pandas is a Python library that is used for faster data analysis, data
cleaning and data pre-processing.
• Pandas is built on top of numpy. So, numpy gets some superpower
with pandas.
• It provides various data structures and operations for
manipulating numerical data and time series.
• Pandas is fast and it has high performance & productivity for users.
• Installation and importing of pandas library is done same as what we
did with Numpy.

19
 Pandas generally provide two data structures for manipulating data, They
are:
• Series
• DataFrame
 Series:
 Pandas Series is a one-dimensional labelled array capable of holding data of any
type (integer, string, float, python objects, etc.).
 Dataframe:
 Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous
tabular data structure with labeled axes (rows and columns).

2
0
Dataframe:
Pandas DataFrame consists
of three principal components,
the data, rows, and columns.

21
Creating a DataFrame:
In the real world, a Pandas DataFrame will be created by loading the
datasets from existing storage,like SQL Database, CSV file, an Excel file.
Pandas DataFrame can be created from the lists, dictionary, and from a list of
dictionaries, etc.

22
Creating a DataFrame:
If we have some data in our CSV file and we want to read that, then we can
use the read_csv() method to read the data in pandas. You just need to pass
the file name or path as the parameter of the method.

23
Info about the dataset Statistics of the dataset

24
Display single column Display multiple columns

25
Create new column Drop a column

26
Python Packages

• Package in Python is a folder that contains


various modules as files.
• Python modules may contain several classes,
functions, variables, etc. whereas Python packages
contain several modules.
Let's create a package named mypackage, using the
following steps:

•Create a new folder named D:\MyApp.


•Inside MyApp, create a subfolder with the name 'mypackage'.
•Create an empty __init__.py file in the mypackage folder.
•Using a Python-aware editor like IDLE, create modules greet.py and
functions.py with the following code:
greet.py
functions.py

We have created our package called mypackage.


Importing a Module from a Package

You might also like