Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views28 pages

Grade-XII-IP - Ch-1 - Series Notes

The document outlines the syllabus for the Informatics Practices subject for Class XII, detailing five units with specific marks allocation. It provides an in-depth introduction to the Pandas library, covering data handling, data structures, and operations such as creating and manipulating Series and DataFrames. Key features, syntax, and functions related to data visualization and analysis using Pandas are also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views28 pages

Grade-XII-IP - Ch-1 - Series Notes

The document outlines the syllabus for the Informatics Practices subject for Class XII, detailing five units with specific marks allocation. It provides an in-depth introduction to the Pandas library, covering data handling, data structures, and operations such as creating and manipulating Series and DataFrames. Key features, syntax, and functions related to data visualization and analysis using Pandas are also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

-

INFORMATICS PRACTICES
Subject Code - 065
Class XII (2025-26)

SYLLABUS:
Unit No Unit Name Marks
1. Data Handling using Pandas and Data Visualization 25
2. Database Query using SQL 25
3. Introduction to Computer Networks 10
4. Societal Impacts 10
5. Project – Practical 30
CHAPTER-1 DATA HANDLING USING PANDAS –I
Pandas:
Pandas is one of the most important and useful open source python’s library for Data
Science.
It is basically used for handling complex and large amount of data efficiently and easily.
Python library developed by Wes McKinney and derived its name from “Panel Data System”.

Features of Panda:-
● It supports data visualization excellently.
● It handles large data efficiently.
● It can read data in many format.
● It makes data customizable and flexible.
● It handles missing and duplicate data efficiently.
● Less writing and more work done.

Data Structure:-
1) Series:- (1-D data structure/ store homogeneous data/ size immutable)
2) Dataframe:- (2-D data structure/ store heterogeneous data/ size mutable)
3) Panel:- (3-D data structure)

Series:-
Series is an important data structure of pandas. It represents a one-dimensional array,
containing an array of data. It can be any type of NumPy data. Basically series has two main
components:
● An Array
● An index associated with an array

Creating Series:
● Syntax of importing Panda Library:
import pandas as <object name>
ex:- import pandas as pd
● Series() function is used to create a series in Pandas.
● Syntax: <Series object>=<panda object>.Series(data=<value>,index=<value>)
Ex:- S=pd.Series(data=[10,20,30,40],index=[‘a’,’b’,’c’])
● Series() can have two arguments as data & index, which can be taken in any order.
● Index argument is optional.
● It can be made on any data such as python sequence.
● We can assign value of any data type as index.
● We can skip keyword data for assigning values to series object.
Empty Series:-
Import pandas as pd
S=pd.Series()
* An empty panda series has float64 datatype.
Non-empty Series:-
In non-empty series data and index will be supplied while creating series. Here data
can be one of these data types:
1. A python sequence
2. An ndarray
3. A dictionary
4. A scalar value
Creating series with a python sequence:
Range function is used to generate a series with python pandas.

Creating Series with ndarray:


Without Indexing:-
With Index:-

Creating series with a dictionary:-


● Key of dictionary is always treated as index of Series object.
● Values of dictionary are always treated as data of series object.
● Syntax:- <series object>=<panda object>.Series(<dictionary object>)
Creating series with a scalar value:-
● Scalar value refers to single value passed for creating series object.
● Index argument must be passed while creating series object using scalar value.
● Syntax: <Series object>=<panda object>.Series(scalar value, index=<sequence>)

Specifying missing values in series object:


To represent missing values for series objects, we can use
● None
● Np.NaN
Creating series using mathematical operation:
We can provide data for series() method by implementing mathematical expression
that can calculate for data sequence.
Syntax: <series object>=<panda
object>.Series(<mathexpression>,index=<sequence>)
Program-1: Mathematical Addition:

Program-2: Mathematical Subtraction:

Program-3: Mathematical Multiplication:


Program-4: Mathematical Division:

Program-5: Mathematical Operations with matching and non-matching values:

Program-6: Mathematical Operations with NumPy array:


Vectorisation on Series objects:
When we apply a function or expression to an object, it is applied individually to
each item of the object. This process is called vectorisation in Python.

Accessing Elements of Series Object:


We can access elements of series objects in two ways:
Indexing:
● We can access individual element of series object.
● We can access multiple elements of series object that may not be contiguous
element.
● Indexing can be used in two ways: positional index, labelled index.
● In positional index an integer value is taken which represent specific element.
● In labelled index any user defined label as index is taken.
Accessing multiple elements using index and modifying a series element:

Slicing:
● Extracting a specific part of series object is called slicing.
● Subset occurred after slicing contains contiguous elements.
● Slicing is done using positions not index of the series object.
● In positional slicing value of end index is excluded.
● If labels are used in slicing than value at end index label is also included.
● Slicing can also be used to extract slice elements in reverse order.
Slicing Series:
Sorting a Series elements:
Program-1: Sorting Data in ascending order:

Program-2: Sorting Data in descending order:

Program-3: Sorting index in ascending order:


Program-4: Sorting index in descending order:

Head and Tail Functions in Series:


head (): It is used to access the first 5 rows of a series.
Note: To access first 3 rows, we can call series_ name. head (3)

tail (): It is used to access the last 5 rows of a series.


Note: To access last 4 rows, we can call series_name. tail (4).
DATAFRAME:-

It is a two-dimensional object that is useful in representing data in the form of rows and
columns. It is similar to a spreadsheet or an SQL table. This is the most commonly used
pandas object. Once we store the data into the Dataframe, we can perform various
operations that are useful in analysing and understanding the data.

Features of Dataframe:-

● Can store heterogeneous data.


● Size mutable.
● Data mutable.
● Can label both index.
● Index may constitute any type of value like number, string, character,
Boolean etc.
● Index of Dataframe can referred as ‘axis’. Axis=0 refers to row index and
axis=1 refers to column index.
A Dataframe can be created using any of the following.
● List
● NumPy 2D array(ndarray)
● Dictionary
● Series
Creating Dataframe:-
Syntax:
import pandas as pd
dfo=pandas.DataFrame(<2DDataStructure>,<columns=column_sequence>,<index=in
dex_sequence>,<dtype=data_type>,<copy=bool>)
Creating empty Dataframe:-
To create an empty Dataframe, DataFrame () function is used without passing any
parameter and to display the elements print () function is used as follows:

Creating DataFrame from List:-


DataFrame can be created using a list for a single column as well as multiple
columns.

Creating DataFrame from NumPy 2D Array/ ndarray:-


To create DataFrame using ndArray, ndArray should be created by importing NumPy
Module.

Creating DataFrame from Dictionary:-


Dictionary objects are also 2D data structures and can be passed to DataFrame ()
Function. Users can create DataFrame from the dictionary of Series and a list of
Dictionaries.
Creating DataFrame from series:-
A DataFrame can be also created from series.

Operations in Dataframe:-
Selecting a column: To access a column in a DataFrame, we can call it’s by name.
Adding a column:
We can add a new column to an existing DataFrame.

Adding a row:
We can add a new row by using loc() or concat() as given below examples.
Through concat():
Deleting a column:
By del function:
By pop function:

By drop function:
Deleting row by drop function:
Renaming the column name:
The rename() function can be used to rename the columns in pandas.

Using head() function with DataFrame:


In pandas head() function is used to show first five rows of the Dataframe. But to display
number of rows u want we need to pass the parameter with function as shown below
example.
Using tail() function with DataFrame:
In pandas tail() function is used to show last five rows of the Dataframe. But to display
number of rows u want we need to pass the parameter with function as shown below
example.
Indexing using Labels in DataFrame:
In Pandas, the term "label-based indexing" refers to the use of explicit labels to retrieve data in a
DataFrame. These labels, which might be row and column names, improve the readability and
intuitiveness of the data processing process.

Using loc for Label-Based Indexing:


Using loc for multiple columns:

Using iloc method:


This is an index based selecting method, which means to choose a certain row or column.
Boolean indexing in data frame:
Boolean indexing helps us to select the data from the DataFrame using a boolean vector. We
create a DataFrame with a boolean index to use the boolean indexing.
Difference between Series & Dataframe:

SERIES DATAFRAME

It is a one dimensional array like structure. It is a two dimensional array like structure,
consists of rows and columns.

It stores homogeneous data. In a series It stores heterogeneous data. In a


object, all of the elements must be of the DataFrame object, the elements can be of
same datatype. different data types.

Series is size immutable, i.e., the size of the Dataframe is size mutable, i.e., the size of
object of series cannot be changed. the object can be changed.

Value of the series is mutable. The value of Value of DataFrame is mutable. The value
elements can be changed. of elements can be changed.

You might also like