Data Handling using pandas
–I
Presented by : dinesh mehra
Pgt (computer science / i.p.)
Introduction
• Python libraries contain a collection of built in modules that allow us
to perform many actions. Without writing detailed programing for it.
• Each library in python contains a large number of modules that one
can import and use.
Example of Python Libraries
numpy pandas matplotlib
Example of Python Libraries numpy
Numpy, stand for ‘Numerical Python’, is a library we can be used for
numerical data analysis and scientific computing. NumPy uses a
multidimensional array object and has functions and tools for working
whit these arrarys. Elements of an array stay together in memory ,
hensen,the can be quickly accessed.
Example of Python Libraries • pandas
Pandas is the python library for data analysis
panda has derived its name from “ PANel Data
System”. It is very easy to import and export
data using pandas library which has a very rich
set of functions.
Why PANDAS
• 1. it can read or write in many different formats(int, float, double,
etc.)
• 2. it can calculate in all possible ways data is organize, i.e. across rows
and down columns.
• 3. it can easy select subset od fata from bulky data sets and even
combine multiple data sets together.
• 4. it has the functionality to find and fill missing data.
• It allows you to apply operations to independent group within the
data.
Installing pandas
Installing pandas
• To install pandas from command line we need to type in :
pip install pandas
Series , DataFrame
• A data structure is a particular way of organizing and
storing data in a a computer , so as to a
• Two commonly used data structures in pandas that
we will cover :
• 1. Series
• 2. DataFrame
Difference between Series and DataFrame
CREATION OF
DATA SERIES
Series
•A series is a ONE DIMENSIONAL ARRAY
containing a sequence of value of any
data type (int, float, list, string, etc.)
•Which by default have numeric data
labels starting from zero.
SERIES
•The data label associated with a
particular value is called its index.
•We can also assign values of other
data types as index.
SERIES
•A series type object has two main
components:
An array of actual data
An associated array of indexes
Series
• Examples :
Index values
0 Krishna
1 Rahul
2 Hemant
3 Jayant
4 Milian
C R E AT I N G A S E R I E S
Series
creation
Empty Non empty
series series
Create Empty Series
• Use Series(), to create an empty Series object
Import pandas library
Call Series() – S is in uppercase
Print Series Object
Create an empty Series object with no values.
Default Data type is : object
CREATING NON EMPTY SERIES
To create a non – empty series object, you need to specify argument
for data and indexes
Syntax :
<seriesobject>=pd.Series(data,index=idx)
if we do not explicitly specify an index for the data values while creating a series,
then by default indices range from 0 through N - 1
CREATING NON EMPTY SERIES
We can create non empty series from any of the following.
C R E AT I N G A S E R I E S F R O M S T R I N G
C R E AT I N G A S E R I E S F R O M L I S T
C R E AT I N G A S E R I E S F R O M L I S T
C R E AT I N G A S E R I E S F R O M T U P L E
ENTER MANUAL INDEX VALUES
Creating a Series From Dictionary
Using
NumPy
SCALAR MEANS SINGLE VALUE