0% found this document useful (0 votes)
243 views225 pages

Informatics Practices Class 12

Uploaded by

ranchanayadav00
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)
243 views225 pages

Informatics Practices Class 12

Uploaded by

ranchanayadav00
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
You are on page 1/ 225

INFORMATICS

PRACTICES
Python Pandas Chapter 1 Part 1
Series Object

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Pandas is an open source Python package that is most widely used for data science/data analysis
and machine learning tasks. It is built on top of another package named Numpy, which provides
support for multi-dimensional arrays. As one of the most popular data wrangling packages,
Pandas works well with many other data science modules inside the Python ecosystem.
Pandas makes it simple to do many of the time consuming, repetitive tasks associated with
working with data, including:
1. Data cleansing
2. Data fill
3. Data normalization
4. Merges and joins
5. Data visualization
6. Statistical analysis
7. Data inspection
8. Loading and saving data
9. And much more
10. In fact, with Pandas, you can do everything that makes world-leading data scientists vote
Pandas as the best data analysis and manipulation tool available.
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Introduction
Pandas or Python Pandas is Python’s library for data analysis. Pandas has been
derived from its name “panel data system”. pandas has become a popular
choice for data analysis. The main author of Pandas is Wes McKinney.

Using Pandas
Pandas is an open source, BSD(Berkely Software Distribution License are used for
distribution of freeware, shareware & Open Source Software) library built for
Python programming language. To work with Pandas in Python, you need to
import pandas library in your python environment.
import pandas as pd

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Why Pandas
Pandas is the most popular library for scientific Python ecosystem for doing data
analysis.
a. It can read or write in many different data formats (integer, float, double
etc.)
b. It can calculate in all the possible ways data is organized i.e. across rows
and columns.
c. It allows you to apply operations to independent groups within the data.
d. It supports reshaping of data into different forms.
e. Supports advanced time-series functionality (predict future values based on
previously observed values)
f. It supports data visualization using matplotlib and seaborn libraries.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Python Data Structure
A data structure is a particular way of storing and organizing data in a computer to suit a
specific purpose so that it can be accessed and worked with appropriate ways.

As per our syllabus we have study two types of data structure:


a. Series
b. DataFrame

Series is a one dimensional data structure of Python Pandas and DataFrame is a two
dimensional data structure of Python Pandas. Pandas also supports another data
structure called Panel, but this is not in our syllabus so we will be covering only two of
them i.e. Series & DataFrame.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Series Vs Dataframe

Property Series DataFrame


Dimensions One Dimensional Two Dimensional
Types of data Homogeneous i.e. all the Heterogeneous, i.e. a DataFrame object
elements must be of same can have elements of different data
data type i.e Series Object types.
Mutability Value mutable, Size Value mutable, Size mutable
immutable

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Series Data Structure
Series is an important data structure of pandas. it represents a one dimensional array of
indexed data. A series type object has two main parts:
a. An array of actual data
b. An associated array of indexes
0 1 2 3 4 5 6 Index
10 20 30 40 50 60 70 Value

Creating Series object


Series object may be created by following ways:
a. A python sequence [List/Tuple] b. An ndarray
c. A Python dictionary d. A scalar value

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
1. Data as Python Sequence Example 2. Write code to create a Series
object using the Python sequence
Example 1. Write code to create a series
(11,21,31,41). Assume that Pandas is
object using the Python sequence
imported as alias name pd.
[4,6,8,10]. Assume that Pandas is imported
as alias name pd.
import pandas as pd
import pandas as pd s2=pd.Series((11,12,13,14))
s1=pd.Series([4,6,8,10]) print(“Series Object”,s2)
print(“Series Object”,s1)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example 3. Write a program to create a Example 4. Write a program to create a
series object using individual characters Series object using a string: “So Funny”.
‘a’, ‘e’, ‘i’, ‘o’ and ‘u’. Assume that Assume that Pandas is imported as alias
Pandas is imported as alias name pd. name pd.

import pandas as pd import pandas as pd


s3=pd.Series([‘a’,’e’,’i’,’o’,’u’]) s4=pd.Series((“So Funny”))
print(“Series Object”,s3) print(“Series Object”,s4)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example 5. Write a program to create a series
object using three different words: “I”, “am”,
“laughing”. Assume that Pandas is imported as
alias name pd.

import pandas as pd
s5=pd.Series([‘apple’,’boy’,’cat’,’dog’,’egg’])
print(“Series Object”,s5)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
linspace() function
2. Specify data as ndarray
This function returns given number of elements
Here we will use the concept of numpy to
between a given range.
create Series object.
For example:

Example 6: Write a program to create a Series


object using an ndarray that has 5 elements in import numpy as np
the range 24 and 64. np.linspace(2.0,3.0,5)
#It will given 5 elements between 2.0 & 3.0
import pandas as pd Output:
import numpy as np array([2.0,2.25,2.5,2.75,3.0]
s6=pd.Series(np.linspace(24,64,5))
print(s6)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example 7: Write a program to create a Series tile() function
object using an ndarray that is created by tiling a
list [3,5], twice. This function replicates the given data n number
of times.
For example:
import pandas as pd
import numpy as np
s7=pd.Series(np.tile([3,5],2)) import numpy as np
print(s7) np.tile([3,4,5],2)
#It will given repeat [3,4,5] two times.
Output: Output:
0 3
array([3,4,5,3,4,5])
1 5
2 3
3 5

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
3. Specify data as Python Dictionary Output:
A 39
Example 8: Write a program to create a Series B 41
object using a dictionary that stores the C 42
number of students in each section of class 12
in your school. D 44

import pandas as pd
stu={‘A’:39,’B’:41,’C’:42,’D’:44}
s8=pd.Series(stu)
print(s8)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
4. Specify data as a Scalar Value Output:
If data is a scalar value, then the index 1.
argument to Series() function must be provided.
0 10
Example:
2.
medalwon=pd.Series(10,index=range(0,1))
1 15
medals2=pd.Series(15,index=range(1,6,2))
3 15
ser2=pd.Series(‘Yet to
5 15
Start’,’index=[‘Indore’,’Delhi’,’SHimla’])
3.
Indore Yet to Start
Delhi Yet to Start
Shimla Yet to Start

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example 9: Write a program to create a Series object Output:
that stores the initial budge allocated (50000/- each) for Qtr1 50000
the four quarters of the year: Qtr1, Qtr2, Qtr3, Qtr4
Qtr2 50000
Solution:
Qtr3 50000
import pandas as pd
Qtr4 50000
s9=pd.Series(50000,index=[‘Qtr1’,’Qtr2’,’Qtr3’,’Qtr4’])
print(s9)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example 10: The number of medals to be won Output:
is 200 in the Inter University games held every 2020 200
alternate year. Write code to create a Series
object that stores these medals for games to 2022 200
be held in the decade 2020-2029. 2024 200
Solution: 2026 200
import pandas as pd 2028 200
s10=pd.Series(200,index=range(2020,2029,2))
print(s10)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating Series Object – Additional Functionality Output:
0 6.50
a. Specifying/Adding NaN values in a Series Object 1 NaN
Sometimes, we need to create a series object of a
2 2.34
certain size bt we don’t have the complete data. In
such case for missing data we use NaN (Not a
Number) value.

For Example:
import pandas as pd
import numpy as np
obj3=pd.Series([6.5,np.NaN,2.34])
print(obj3)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating Series Object – Additional Functionality Output:
b. Specify index(es) as well as data with Series() Jan 31
Sometimes, we need to specify indexes as well as Feb 28
data. We have also the provision for the same.
Mar 31
Apr 30
For Example:
import pandas as pd
import numpy as np
arr=[31,28,31,30]
mon=[“Jan”,”Feb”,”Mar”,”Apr”]
obj3=pd.Series(data=arr,index=mon)
print(obj3)
(Here we can skip the keyword “data”)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating Series Object – Additional Functionality Output:
b. Specify index(es) as well as data with Series()
Jan 31
Sometimes, we need to specify indexes as well as data. We
have also the provision for the same. Feb 28
Mar 31
For Example:
import numpy as np Apr 30
import pandas as pd
month=[]
value=[]
for i in range(4):
z=input("Enter Month Name:")
month.append(z)
x=int(input("Enter Number of Days:"))
value.append(x)
obj=pd.Series(data=value,index=month)
print(obj)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Creating Series Object – Additional Functionality Output:
Example 11: A python list namely section stores the A 6700
section names(‘A’,’B’,’C’,’D’) of class 12 in your B 5600
school. Another list contri stores contribution made by
these students to a charity fund endorsed by the C 5000
school. Write code to crate a Series object that stores D 5200
the contribution amount as the values and the
section names as the indexes.

import pandas as pd
section=[‘A’,’B’,’C’,’D’]
contri=[6700,5600,5000,5200]
s11=pd.Series(data=contri,index=section)
print(s11)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Creating Series Object – Additional Functionality Output:
C. Specify data types, index(es) as well as data with Series() A 6700.0
We can also specify data type along with data and index B 5600.0
with Series() as per the following syntax:
C 5000.0
<series
object>=pandas.Series(data=None,index=None,dtype=None) D 5200.0

For Example:
import pandas as pd
import numpy as np
section=[‘A’,’B’,’C’,’D’]
contri=[6700,5600,5000,5200]
s11=pd.Series(data=contri,index=section, dtype=np.float64)
print(s11)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Creating Series Object – Additional Functionality Output:
D. Creating a Mathematical Function/Expression to Create 9 18
Data Array in Series()
10 20
The Series() allow you to define a function or expression that
can calculate values for data sequence. It is done in the 11 22
following form: 12 24
<series
object>=pandas.Series(index=None,data=<function|expressio
n>)

For Example:
import pandas as pd
import numpy as np
a=np.arange(9,13)
obj=pd.Series(index=a,data=a*2)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Creating Series Object – Additional Functionality Output:
D. Creating a Mathematical Function/Expression to Create 9 81
Data Array in Series() 10 100
Another Example: 11 121
12 144
import pandas as pd
import numpy as np
a=np.arange(9,13)
obj=pd.Series(index=a,data=a**2)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
import pandas as pd Output:
import numpy as np A 13400.0
section=[‘A’,’B’,’C’,’D’,’E’] B 11200.0
contri=np.array([6700,5600,5000,5200,np.Nan]) C 10000.0
obj=pd.Series(data=contri*2,index=section,dtype=np.float64) D 10400.0
print(obj) E NaN
dtype: float32
Note:
To store NaN value, the datatype must be Float as it’s
capacity lies in Float, even if you store any integer, it will
convert that to Float.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Indices need not be unique in Pandas Series Object. Output:
a 2.75
import pandas as pd b 12.50
import numpy as np a 22.25
val=np.arange(2.75,5.,9.75) a 32.00
obj=pd.Series(val,index=[‘a’,’b’,’a’,’a’,’b’]) b 41.75
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Series Object Attributes

Attribute Description
<Series object>.index Displays the indexes of the series.
<Series object>.values Displays the values of the series.
<Series object>.dtype Displays the datatype of the data.
<Series object>.shape Displays the number of elements in the series object.
<Series object>.nbytes Returns number of bytes in underlying data.
<Series object>.ndim Returns the number of dimensions of series object.
<Series object>.size Returns the number of elements in series object.
<Series object>.hasnans Returns True if there are any NaN values; otherwise return False.
<Series object>.empty return True if the Series Object is empty, otherwise False.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Accessing a Series Object and its Elements.
a. Accessing individual elements
<Series Object name>[<valid index>]

Example:
import pandas as pd
obj=pd.Series([5,10,15,20,25])
print(obj[1]) #will print 10
print(obj[3]) #will print 20

Note: if the series object has duplicate indexes, it returns all the
respective values. Accessing an index which is not there in
Series object, gives error.
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Extracting Slices from Series Object
Like other sequences, we can extract slice too from a Series object to retrieve subsets.
We need to understand the most important concept for slicing which is:
“Slicing takes place position wise and not the index wise in a series object.”
The following syntax has to be followed:
obj[start:end:step]

So if your Series object is:


index Values Position
Jan 31 0
Feb 28 1
Mar 31 2
Apr 30
Created By: Anand Sir, YouTube Channel: CODEITUP 3
Python Pandas
Extracting Slices from Series Object
import pandas as pd Output:
obj=pd.Series(data=[31,28,31,30,31],index=['Jan','Feb','Mar','Apr','May']) Mar 31
Apr 30
print(obj[2:4])

Output:
import pandas as pd
Mar 31
obj=pd.Series(data=[31,28,31,30,31],index=['Jan','Feb','Mar','Apr','May']) Apr 30

print(obj[2:]) May 31

Output:
import pandas as pd Jan 31

obj=pd.Series(data=[31,28,31,30,31],index=['Jan','Feb','Mar','Apr','May']) Mar 31
May 31
print(obj[0::2])
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Extracting Slices from Series Object
Output:
Reversing Series Object May 31

import pandas as pd Apr 30


Mar 31
obj=pd.Series(data=[31,28,31,30,31],index=['Jan','Feb','Mar','Apr','May'])
Feb 28
print(obj[::-1]) Jan 31

Ques: Consider a Series object s8 that stores the number of students in each section of class 12 (as shown below).
A 39
B 41
C 42
D 44
First two sections are assigned to sell ticket @100. Count how much they will collect?

import pandas as pd
print(“Tickets Amount”)
print(s8[:2]*100)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Operations on Series Object
1. Modifying Elements of Series Object
The data values of a Series object can be easily modified through item assignment i.e.
<SeriesObject>[<index>]=<new_data_value>
So if your Series object is:
index Values
Jan 31
Feb 28
Mar 31
Apr 30
Now, you want to modify the data you can do like this:
obj[‘Feb’]=29
now,Created
when you
By: Anand willChannel:
Sir, YouTube printCODEITUP
the object, you will get the modified value i.e. 29 instead of 28 days in feb.
Python Pandas
Operations on Series Object
1. Renaming Indexes
We can change the index as well of a Series object. One thing to note is that the size of new index array
must match with existing index array’s size. The way is:
<Object>.index=<new index array>
<SeriesObject>[<index>]=<new_data_value>
So if your Series object is:
index Values
Jan 31
Feb 28
Mar 31
Apr 30
Now, you want to modify the data you can do like this:
obj.index=[‘’A’,’B’,’C’,’D’,’E’]
now, when you will print the object, you will get the updated index.
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Example: Consider the Series object s13 that stores the contribution of each section, as shown
below:
A 6700
B 5600
C 5000
D 5200
Write code to modify the amount of section ‘A’ as 7600 and for sections ‘C’ and ‘D’ as 7000. Print
the change object.
import pandas as pd
s13=pd.Series(data=[6700,5600,5000,5200],index=[’A’,’B’,’C’,’D’])
s13[‘A’]=7600
s13[2:]=7000
print(obj)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
The Head() and tail() functions:
The head() function is used to fetch first n rows from a Pandas object and tail() function return last n
rows from a Pandas object. The syntax is:
<pandas object>.head([n])
<panda object>.tail([n])
if no value is being provided for “n”, it is going to return first 5 rows from top and bottom
respectively.

import pandas as pd
obj=pd.Series(data=[31,28,31,30,31,30],index=['Jan','Feb','Mar','Apr','May','Jun'])
print(obj.head())
print(obj.tail())

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: A Series object trdata consist of around 2500 rows of data. Write a program to print the
following details: a. First 100 rows of data b. Last 5 rows of data

import pandas as pd
.......
.......
print(trdata.head(100))
print(trdata.tail(5))

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Vector Operations on Series Object
Vector operations mean that if you apply a function or expression then it is individually applied on
each item of the object.

import pandas as pd
obj=pd.Series([5,10,15,20,25])
obj=obj+2
print(obj)

The series object first will be created as: [5,10,15,20,25]


After the line obj=obj+2 it will become: [7,12,17,22,27]

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Arithmetic on Series Object
Arithmetic operations such as addition, subtraction, division etc can be done with two series object and
it will calculate result on two corresponding items of the two object given in the expression but
remember, it performs operation only on matching indexes. For the matching indexes, it will perform the
calculation and for all others it will show NaN(not a Number).
For Example:
import pandas as pd
obj1=pd.Series([1,2,3,4,5])
obj2=pd.Series([1,2,3])
print(obj1+obj2)

0 2.0
1 4.0
2 6.0
3 NaN
4 NaN
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Example: Number of students in class 11 and 12 in three streams (‘Science’,’Commerce’ and
‘Humanities’) are stored in two Series objects c11 and c12. Write code to find total number of
students in class 11 and 12, stream wise.
Solution:
import pandas as pd
c11=pd.Series(index=[‘Science’,’Commerce’,’Humanities’], data=[50,55,62])
c12=pd.Series(index=[‘Science’,’Commerce’,’Humanities’], data=[45,50,55])
print(“Total Number of students:”)
print(c11+c12)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Object1 Population stores the details of population in four metro cities of India and Object2
AvgIncome stores the total average income reported in previous year in each of these metros. Calculate
income per capita for each of these metro cities.

Solution:
import pandas as pd
population=pd.Series([123456,253641,32146,652314],index=[‘Delhi’,’Mumbai’,’Kolkata’,’Chennai’])
avgincome=pd.Series([12345678,87654321,2345678,34567891],index=[‘Delhi’,’Mumbai’,’Kolkata’,’Chennai’])
print(population/avgincome)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Filtering Entries
We can filter out entries from a Series Object using a Boolean expression and this expression will be applied to
each element of the Series object and you will be given the set of values which passes that Boolean expression.

For Example:
ob1>5 # Now all those elements having value>5 will return True otherwise False.
ob1[obj1>5] #Now this will return you the values satisfying the condition.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example 19: What will be the output of the following program?
import pandas as pd
info=pd.Series(data=[31,41,51])
print(info)
print(info>40)
print(info[info>40])
Output:
0 31
1 41
2 51
0 False
1 True
2 True
1 41
2 51
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Example 20: Series object s11 stores the charity contribution made by each section section as below:
a 6700
b 5600
c 5000
d 5200
Write a program to display which sections made a contribution more than 5500/-.

import pandas as pd
s11=pd.Series(data=[6700,5600,5000,5200],index=[‘a’,’b’,’c’,’d’])
print(s11[s11>5500])

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Sorting Series Values
You can sort the values of a Series Object on the basis of values and indexes.
On the basis of values
obj.sort_values()
OR
obj.sort_values(ascending=False)

On the basis of indexes:


obj.sort_index(ascending=True|False)
Here, True is optional as by default the order is ascending order while to make that to descending, False has to
be written.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Difference between Numpy Arrays and Series Object
The major differences in ndarrays and Series objects are:
1. In ndarray, vectorized operations can be performed only when the shape are equal otherwise it will return
false. In case of Series object, it can be performed irrespective of shape. For the similar indexes it will provide
you the value and for non matching indexes it will provide NaN.
2. In ndarray indexes are always numeric starting from 0 onwards whereas it is not so in Series object.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Reindexing
obj1=obj2.reindex([‘e’,’d’,’c’,’b’,’a’])
This statement is going to create a obj1 with the help of obj2 but using the re-indexing mechanism. Here obj2 will
be reindexed as per the indexing provided and obj1 will be created with the same order i.e. first element’s
index of obj1 will be ‘e’, then ‘d’, then ‘c’, ‘b’, and ‘a’.

Dropping elements:
obj2=obj2.drop(‘c’)
Will delete the index c from obj2.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Python Pandas Chapter 1 Part 2
DataFrame Object

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
DataFrame Object
A DataFrame is another Pandas structure, which stores data in two-dimensional way. it is actually a two
dimensional (Tabular) labelled array, which is an ordered collection of columns where the columns may contain
different types of data.

Characteristics:
Major characteristics of a DataFrame data structure are:
a. It has two indexes or we say that two axes – a row axis ( index 0) and a column index (axis=1).
b. Every set of data is available with the combination of row index and column name.
c. The numbers can be numbers or letters of strings.
d. There is no condition of having all data of same type across columns.
e. Values mutable.
f. You can add or delete rows/columns in a DataFrame.
For Example: Roll Name Marks
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Creating and Displaying a DataFrame
A DataFrame object can be created by passing data in two-dimensional format. So, the following two lines of
code will be mandatory:
import pandas as pd #to import pandas
import numpy as np #to import numpy

To create a dataframe object, the syntax is:


<dataframe object>=panda.DataFrae(<2d Array>, [columns=....],[index=....])

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating DataFrame Object
a) Creating a dataframe from a 2D dictionary having values as list/ndarray.
import pandas as pd
dict1={'students':['Ram','Shyam','Sita','Gita','Mita'],
'Marks':[90,89,95,85,80],'sport':['Cricket','Badminton','Football','Athletics','Kabaddi']}
data=pd.DataFrame(dict1)
print(data)

b)
import pandas as pd
dict1={'students':['Ram','Shyam','Sita','Gita','Mita'],
'Marks':[90,89,95,85,80],'sport':['Cricket','Badminton','Football','Athletics','Kabaddi']}
data=pd.DataFrame(dict1,index=['I','II','III','IV','V'])
print(data)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Example: Given a dictionary that stores the section name’s list as value for ‘Section’ key and contribution
amounts’ list as value for ‘Contri’ key.
dict1={‘Section’:[‘A’,’B’,’C’,’D’],’Contri’:[6700,5600,5000,5200]}
write code to create and display the data frame using above dictionary.

import pandas as pd
dict1={‘Section’:[‘A’,’B’,’C’,’D’],’Contri’:[6700,5600,5000,5200]}
obj=pd.DataFrame(dict1)
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating a dataframe from a 2D dictionary having values as dictionary objects:
import pandas as pd
people={‘sales’:{‘name’:’Rohit’,’age’:’24’,’sex’:’Male’},’Marketing’:{‘name’:’Neha’,’age’:’25’,’sex’:’Female’}}
obj=pd.DataFrame(people)
print(obj)

Output:
Marketing Sales
name Neha Rohit
age 25 24
sex Female Male

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Create and display a DataFrame from a 2D dictionary, Sales, which stores the quarter wise sales as inner
dictionary for two years as shown below:
sales={‘yr1’:{‘Qtr1’:35400,’Qtr2’:56000,’Qtr3’:47000,’Qtr4:49000},’yr2’:{‘Qtr1’:44900,’Qtr2’:46100,’Qtr3’:57000,’Qtr4:59000}}

import pandas as pd
sales={‘yr1’:{‘Qtr1’:35400,’Qtr2’:56000,’Qtr3’:47000,’Qtr4:49000},’yr2’:{‘Qtr1’:44900,’Qtr2’:46100,’Qtr3’:57000,’Qtr4:59000}}
data=pd.DataFrame(sales)
print(data)

Output:
yr1 yr2
Qtr1 35400 44900
Qtr2 56000 46100
Qtr3 47000 57000
Qtr4 49000 59000
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Now as per the example in the previous slide, there may be some non matching indexes / values may not be
there. For instance consider the following example;
collect1={‘yr1’:1500, ‘yr2’:2500}
collect2={‘yr1’:2200,’Nil’:0}
collect={‘I’:collect1,’II’:’collect2}
obj=pd.DataFrame(collect)
print(obj)

Output:
I II
yr1 1500 2200
yr2 2500 NaN
Nil NaN 0

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Carefully read the following code: Ques 1: List the index labels of the DataFrame df3.
import pandas as pd Qtr1, Qtr2, Qtr3, Qtr4, A, B
yr1={‘Qtr1’:44900,’Qtr2’:46100,’Qtr3’:57000,’Qtr4’:50000}
yr2={‘A’:54500, ‘B’:51000,’Qtr4’:57000} Ques 2: List the column names of DataFrame df3
disales1={1:yr1,2:yr2} I, II
df3=pd.DataFrame(disales1)
Output:
1 2
Qtr1 44900 NaN
Qtr2 46100 NaN
Qtr3 57000 NaN
Qtr4 50000 57000
A NaN 54500
B NaN 51000
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Creating DataFrame object from list of Dictionaries/List. Here, by default the indexing mechanism is 0,1,2,and
import pandas as pd so on.

topperA={‘Rollno’:115,’Name’:’Pavni’,’Marks’:97.5} But if we want to change the indexing then we can


do it like:
topperB ={‘Rollno’:236,’Name’:’Rishi’,’Marks’:98}
obj=pd.DataFrame(toppers,index=[“Sec A”,”Sec
topperC ={‘Rollno’:307,’Name’:’Preet’,’Marks’:98.5}
B”,”Sec C”,”Sec D”])
topperD ={‘Rollno’:422,’Name’:’Paula’,’Marks’:98}
toppers=[topperA,topperB,topperC,topperD]
and after this the output would be:
obj=pd.DataFrame(topper)
Output:
Rollno Name Marks
Output:
Rollno Name Marks Sec A 115 Pavni 97.5

0 115 Pavni 97.5 Sec B 236 Rishi 98

1 236 Rishi 98 Sec C 307 Preet 98.5


2 307 Preet 98.5 Sec D 422 Paula 98
3 422 Paula
Created By: Anand Sir, YouTube Channel: CODEITUP 98
Python Pandas
Example: Write a program to create a dataframe from a list containing dictionaries of the sales performance of
four zonal offices. Zone names should be the row labels.
Output:
import pandas as pd Target Sales
dict1={‘Target’:56000,’Sales’:58000} zoneA 56000 58000
dict2={‘Target’:75000,’Sales’:68000} zoneB 75000 68000
dict3={‘Target’:75000,’Sales’:78000} zoneC 75000 78000
dict4={‘Target’:60000,’Sales’:61000} zoneD 60000 61000
zones=[dict1,dict2,dict3,dict4]
obj=pd.DataFrame(zones,index=[‘zoneA’,’zoneB’,’zoneC’,’zoneD’])
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Passing a 2D list to create a DataFrame Object. Output:
import pandas as pd 0 1 3
list1=[[5,10,15],[20,25,30],[35,40,45]] 0 5 10 15
obj=pd.DataFrame(list1) 1 20 25 30
print(obj) 2 35 40 45

Here again if you want, you can change the indexes: Output:
import pandas as pd 0 1 2
list1=[[5,10,15],[20,25,30],[35,40,45]] row1 5 10 15
obj=pd.DataFrame(list1,index=[‘row1’,’row2’,’row3’]) row2 20 25 30
print(obj) row3 35 40 45

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Write a program to create a dataframe from a list containing 2 list, each containing targe and actual
sales figures of four zonal offices Give appropriate row labels.

import pandas as pd
target=[20000,25000,30000,35000]
sales=[22000,26000,29000,36000]
list1=[target,sales]
obj=df.DataFrame(list1,columns=[‘zoneA’,’ZoneB’,’ZoneC’,’zoneD’], index=[‘Target’,’Sales’])

Output:
zoneA zoneB zoneC zoneD
Target 20000 25000 30000 35000
Sales 22000 26000 29000 36000

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating a DataFrame Object from a 2D ndarray Creating a DataFrame Object from a 2D ndarray

import numpy as np import numpy as np


import pandas as pd import pandas as pd
arr=np.array([[1,2,3],[4,5,6]]) arr=np.array([[1,2,3],[4,5,6]])
arr.shape #will show (2,3) arr.shape #will show (2,3)
obj=pd.DataFrame(arr) obj=pd.DataFrame(arr,columns=[‘One’,’Two’,’Three’])
print(obj) print(obj)

Output: Output:
0 1 2 One Two Three
0 1 2 3 0 1 2 3
1 4 5 6 1 4 5 6

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating a DataFrame Object from a 2D ndarray

import numpy as np
import pandas as pd
arr=np.array([[1,2,3],[4,5,6]])
arr.shape #will show (2,3)
obj=pd.DataFrame(arr,columns=‘One’,’Two’,’Three’,index=[‘A’,’B’])
print(obj)

Output:
One Two Three
A 1 2 3
B 4 5 6

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
In the examples till now, the number of elements in each row were same. But suppose there are no fixed
number of element in each row, then python will create a single column.

arr=np.array([[101.5, 201.2],[400,50,60,70],[212.3,524,652.1]])
(now it’s datatype will be “object” as it has different types of element as well as uneven number of elements)
obj=pd.DataFrame(arr)
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: What will be the output of following code>
import pandas as pd
import numpy as np
arr1=np.array([[11,12],[13,14],[15,16],np.int32]])
obj=pd.DataFrame(arr1)
print(obj)

Output:
0 1
0 11 12
1 13 14
2 15 16

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Write a program to create a DataFrame from a 2D array as shown below: 101 113 124
import pandas as pd 130 140 200
import numpy as np 115 216 217
arr1=np.array([[101,113,124],[130,140,200],[115,216,2147],np.int32]])
obj=pd.DataFrame(arr1)
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating a DataFrame object from a 2D Dictionary with Values as Series Object

import pandas as pd Amount People


0 10000 20
staff=pd.Series([20,30,40])
1 12000 30
salary=pd.Series([10000,12000,15000]) 2 15000 40
school={‘People’:staff,’Amount’:salary}
obj=pd.DataFrame(school)
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Consider two Series objects staff and salaries that store the number of people in various office
branches and salaries distributed in these branches respectively. Write a program to create another series
object that stores average salary per branch and then create a DataFrame object from these Series objects.

import pandas as pd
import numpy as np
staff=pd.Series([10,15,20])
salary=pd.Series([100000,1500000,156400])
average=salary/staff
data={‘People’:staff,’Salary’:salary,’Average’:average}
obj=pd.DataFrame(data)
print(obj)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating a DataFrame object from another DataFrame Object

import pandas as pd
data1={'roll':1,'name':'codeitup','age':2}
data2={'roll':2,'name':'fitnesswithanand','age':0}
total=[data1,data2]
obj=pd.DataFrame(total)
obj1=pd.DataFrame(obj)
print(obj1)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
DataFrame Attributes

Attribute Description
<DataFrame object>.index Displays the indexes (row labels) of the DataFrame.
<DataFrame object>.columns Displays the column labels of the DataFrame.
<DataFrame object>.axes Returns a list representing both axes i.e. axis 0 i.e. index and
axis 1 i.e. columns of the DataFrame.
<DataFrame object>.dtypes Returns the dtypes of data in the DataFrame.
<DataFrame object>.size Returns an int representing number of elements in this object.
<DataFrame object>.shape Returns a tuple representing dimension of DF object.
<DataFrame object>.values Returns numpy representation of DF object.
<DataFrame object>.empty Indicator whether DataFrame is empty.
<DataFrame object>.ndim Return an int representing number of axes/array dimensions.
<DataFrame object>.T Transpose index and columns.
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
import pandas as pd
data1={'age':25,'name':'Neha','sex':'Female'}
data2={'age':24,'name':'Rohit','sex':'Male'}
data3={'Marketing':data1,'Sales':data2}
obj=pd.DataFrame(data3)
print(obj)
print(obj.index)
print(obj.columns)
print(obj.axes)
print(obj.dtypes)
print(obj.size)
print(obj.shape)
print(obj.values)
print(obj.empty)
print(obj.ndim)
print(obj.T)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Getting count of non-NaN values in DataFrame
Like Series, you can use count() with dataframe too to get the count of non-NaN or non-NA values.
a) If you do not pass any argument or pass 0, then it returns count of non-NA values for each column:
>>>obj.count() OR >>>obj.count(axis=‘index’)
Marketing 3 Marketing 3
Sales 3 Sales 3
b) If you pass argument as 1, then it returns count of non-NA values for each row.
>>>obj.count(1) OR >>>obj.count(axis=‘columns’)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Example: Write a program to create a DataFrame to store weight, age and names of 3
people. Print the DataFrame and its transpose.

import pandas as pd
dict1={'Weight':68,'age':30,'name':'Ravi'}
dict2={'Weight':78,'age':35,'name':'Raj'}
dict3={'Weight':80,'age':28,'name':'Ramesh'}
list1=[dict1,dict2,dict3]
obj=pd.DataFrame(list1,index=['person1','person2','person3'])
print(obj)
print("===================================")
print(obj.T)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Selecting or Accessing Data
From a DataFrame object, you can extract or select desire row and columns as per your
requirement.
Consider the following dataframe object (let be the name “obj”):
Population Hospitals Schools
Delhi 10927986 189 7916
Mumbai 12691836 208 8508
Kolkata 4631392 149 7226
Chennai 4328063 157 7617

Selecting a column: Selecting Multiple Columns

>>>obj[‘Population’] >>>obj[[‘Schools’,’Hospitals’]]
>>>obj[‘Schools’] >>>obj[[‘Hospitals’,’Schools’]]
>>>obj.population
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Selecting/Accessing a Subset from a DataFrame using Row/Column Names
To access row(s) and/or a combination of rows and column we can use the following
way:
a. To access a row:
obj.loc[‘Delhi’,:] or obj.loc[‘Chennai’,:]
b. To access multiple rows:
obj.loc[‘Mumbai’:’Kolkata’,:]
Please note that when you specify <start row>:<end row>, python will return all rows
falling between start row and end row.
c. To access row in a range:
obj.loc[‘Mumbai’:’Chennai’,:]

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Selecting/Accessing a Subset from a DataFrame using Row/Column Names
To access column(s) we can use the following way:
>>>obj.loc[:,’Population’:’Schools’]
Population Hospitals Schools
Delhi 10927986 189 7916
Mumbai 12691836 208 8508
Kolkata 4631392 149 7226
Chennai 4328063 157 7617
>>>obj.loc[:,’Population’:’Hospitals’]
If it represents a range of column, all the column between the range will be displayed as done in row extraction.
Population Hospitals
Delhi 10927986 189
Mumbai 12691836 208
Kolkata 4631392 149
Chennai 4328063 157
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Extracting Data from range of columns and a range of rows
obj.loc[‘Delhi’:’Mumbai’,’Population’:’Hospitals’]
Population Hospitals
Delhi 10927986 189
Mumbai 12691836 208

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Selecting Rows/Columns from a DataFrame
Sometimes your dataframe object does not contain row or column labels or even you
may not remember them. In such case, you extract subset from dataframe using the
row and column numeric index/position. For this we use iloc.
Population Hospitals Schools
Delhi 10927986 189 7916
Mumbai 12691836 208 8508
Kolkata 4631392 149 7226
Chennai 4328063 157 7617
>>>obj.iloc[0:2,1:3]
Hospitals Schools
Delhi 189 7916
Mumbai 208 8508

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Selecting Rows/Columns from a DataFrame
Sometimes your dataframe object does not contain row or column labels or even you
may not remember them. In such case, you extract subset from dataframe using the
row and column numeric index/position. For this we use iloc.
Population Hospitals Schools
Delhi 10927986 189 7916
Mumbai 12691836 208 8508
Kolkata 4631392 149 7226
Chennai 4328063 157 7617
>>>obj.iloc[0:2,1:2]
Hospitals
Delhi 189
Mumbai 208

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Selecting/Accessing Individual Value
To select/access an individual data values from a dataframe, you can use any of the
following methds:
(i) Either given name of row or numeric index in square bracket.
obj.population[‘delhi’] OR obj.population[0]
obj.population[‘Mumbai’] OR obj.population[1]
(ii) You can use at or iat attributes with DF object as shown below:
Use To
obj.at[<row lable>,<col label>] Access a single value for a row/column
obj.iat[<row index>,<column index>] Access a single value for a row/column
pair by integer position.
Example:
>>>obj.at[‘Chennai’,’School’] >>>obj.iat[3,2]
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Selecting/Accessing Individual Value
To select/access an individual data values from a dataframe, you can use any of the
following methds:
(i) Either given name of row or numeric index in square bracket.
obj.population[‘delhi’] OR obj.population[0]
obj.population[‘Mumbai’] OR obj.population[1]
(ii) You can use at or iat attributes with DF object as shown below:
Use To
obj.at[<row lable>,<col label>] Access a single value for a row/column
obj.iat[<row index>,<column index>] Access a single value for a row/column
pair by integer position.
Example:
>>>obj.at[‘Chennai’,’School’] >>>obj.iat[3,2]
Created By: Anand Sir, YouTube Channel: CODEITUP
INFORMATICS
PRACTICES
Python Pandas Chapter 2 Part 1

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Until now, we have learnt about the two most popular data structure of Python
Pandas data structure called Series and DataFrame.
Series data structure is a one dimensional data structure whereas DataFrame is
a 2D data structure.

Now we are moving towards more about DataFrame concepts.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Iterating over DataFrame
When we need to go through each element of a DataFrame, we can do it
using two functions:
1. iterrows() – This method iterates over dataframe row wise.
2. iteritems() – This method iterates over dataframe column wise.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Program Example
import pandas as pd
sales={'year1': {'Qtr1':5000,'Qtr2':6000,'Qtr3':5500,'Qtr4':6000},\
'year2': {'Qtr1':7000,'Qtr2':8000,'Qtr3':8500,'Qtr4':9000},\
'year3': {'Qtr1':5500,'Qtr2':7000,'Qtr3':7500,'Qtr4':6000}}
dfobj=pd.DataFrame(sales)
for (a,b) in dfobj.iterrows():
print('Row Index :',a,'\nValue=\n',b)

year1 year2 year2


Qtr1 5000 7000 5500
Qr2 6000 8000 7000
Qtr3 5500 8500 7500
Qtr4 6000 9000 6000
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Program Example
import pandas as pd
sales={'year1': {'Qtr1':5000,'Qtr2':6000,'Qtr3':5500,'Qtr4':6000},\
'year2': {'Qtr1':7000,'Qtr2':8000,'Qtr3':8500,'Qtr4':9000},\
'year3': {'Qtr1':5500,'Qtr2':7000,'Qtr3':7500,'Qtr4':6000}}
dfobj=pd.DataFrame(sales)
for (a,b) in dfobj.iterrows():
print('Row Index :',a,'\nContains\n')
year1 year2 year2
for i in b:
Qtr1 5000 7000 5500
print(i) Qr2 6000 8000 7000
Qtr3 5500 8500 7500
Qtr4 6000 9000 6000

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Ques: Write a program to print the DataFrame df, one row at a time.
import pandas as pd
data={'Name':["Ram","Shyam","Sita","Gita"],'Marks':[80,90,85,75]}
df=pd.DataFrame(data)
print("Name\tMarks")
print("________________")
for i,j in df.iterrows():
print(j)
print("________________")

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Ques: Write a program to print the DataFrame df, one column at a time.
import pandas as pd
dict={'Name':['Ram','Shyam','Sita','Gita'],'Marks':[80,90,85,75]}
df=pd.DataFrame(dict)
for i, j in df.iteritems():
print(j)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
We can also print individual column for extracted row using iteritems by using
rowSeries.
import pandas as pd
dict={'Name':['Ram','Shyam','Sita','Gita'],'Marks':[80,90,85,75]}
df=pd.DataFrame(dict)
for (i, j) in df.iteritems():
print(j[‘Marks’])

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Python Pandas Chapter 2 Part 2

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Binary Operations in DataFrame
In a binary operation, two dataframes are aligned o the basis of their row and
column indes and for the matching row, column index, the given operation is
performed and for non matching NaN is stored.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Binary Operations in DataFrame
===================================
import pandas as pd A B C
data={'A':[1,4,7],'B':[2,5,8],'C':[3,6,9]} 0 1 2 3
df1=pd.DataFrame(data) 1 4 5 6
print(df1) 2 7 8 9
===================================
import pandas as pd A B C
data={'A':[10,40,70],'B':[20,50,80],'C':[30,60,90]} 0 10 20 30
df2=pd.DataFrame(data) 1 40 50 60
print(df2) 2 70 80 90
===================================

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Binary Operations in DataFrame
===================================
import pandas as pd A B C
data={'A':[100,400],'B':[200,500],'C':[300,600]} 0 100 200 300
df3=pd.DataFrame(data) 1 400 500 600
print(df3)
===================================
import pandas as pd A B
data={'A':[1000,4000,7000],'B':[2000,5000,8000]} 0 1000 2000
df4=pd.DataFrame(data) 1 4000 5000
print(df4) 2 7000 8000

===================================

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1+df2

OR
>>>df1.add(df2)
Will Give you the result
OR A B C
>>>df1.radd(df2) 0 11 22 33
1 44 55 66
2 77 88 99
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1+df3

OR
>>>df1.add(df3)
Will Give you the result
OR
A B C
>>>df1.radd(df3) 0 101.0 202.0 303.0
1 404.0 505.0 606.0
2 NaN NaN NaN
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1+df4

OR
>>>df1.add(df4)
Will Give you the result
OR A B C

>>>df1.radd(df4) 0 1001.0 2002.0 NaN


1 4004.0 5005.0 NaN
2 7007.0 8008.0 NaN
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1-df2

OR
>>>df1.sub(df2)
Will Give you the result
OR A B C
>>>df2.rsub(df1) 0 9 18 27
1 36 45 54
2 63 72 81
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here: Note:
>>>df1-df3 df1-df2 is equal to df1.sub(df2)
OR df2-df1 is equal to df1.rsub(df2)

>>>df1.sub(df3)
Will Give you the result
OR A B C
>>>df3.rsub(df1) 0 -99.0 -198.0 -297.0
1 -396.0 -495.0 -594.0
2 NaN NaN NaN
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1*df2

OR
>>>df1*mul(df2)
Will Give you the result
OR A B C
>>>df2.rmul(df1) 0 10 40 90
1 160 250 360
2 490 640 810
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1*df3

OR
>>>df1*mul(df3)
Will Give you the result
OR A B C
>>>df1.rmul(df3) 0 100 400 900
1 1600 2500 3600
2 NaN NaN NaN
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1/df2

OR
>>>df1*div(df2)
Will Give you the result
OR A B C
>>>df2.rdiv(df1) 0 0.1 0.1 0.1
1 0.1 0.1 0.1
2 0.1 0.1 0.1
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
A B C A B C A B C A B
0 1 2 3 0 10 20 30 0 100 200 300 0 1000 2000
1 4 5 6 1 40 50 60 1 400 500 600 1 4000 5000
2 7 8 9 2 70 80 90 2 7000 8000

Here:
>>>df1/df3

OR
>>>df1*div(df3)
Will Give you the result
OR A B C
>>>df3.rdiv(df1) 0 0.01 0.01 0.01
1 0.01 0.01 0.01
2 NaN NaN NaN
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Write a program to calculate total points earned by both the teams in each round.

import pandas as pd
data1={'p1':{'1':700,'2':975,'3':970,'4':900},'p2':{'1':490,'2':460,'3':570,'4':590}}
data2={'p1':{'1':1100,'2':1275,'3':1270,'4':1400},'p2':{'1':1400,'2':1260,'3':1500,'4':1190}}
df1=pd.DataFrame(data1)
df2=pd.DataFrame(data2)
print("Team 1's Performance")
print(df1)
print("Team 2's Performance")
print(df2)
print("Joint Performance")
print(df1+df2)

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Python Pandas Chapter 2 Part 3

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Descriptive Statistics with Pandas
Python Pandas is widely used in data science library and it has many useful functions.
Along with many other types of functions, it also offers statistical functions like max(),
min(), mode(), mean(), median() etc

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
We will be taking example of the following data for understanding the functions.
import pandas as pd
import numpy as np
iprod={'Rice':{'Andhra P.':7452.4,'Gujrat':1930.0,'Kerala':2604.8,\
'Punjab':11586.2, 'Tripura':814.6,'Uttar P.':13754.0},
'Wheat':{'Andhra P.':np.NaN,'Gujrat':2737.0,'Kerala':np.NaN,\
'Punjab':16440.5, 'Tripura':0.5,'Uttar P.':30056.0},
'Pulses':{'Andhra P.':931.0,'Gujrat':818.0,'Kerala':1.7,\
'Punjab':33.0, 'Tripura':23.2,'Uttar P.':2184.4},
'Fruits':{'Andhra P.':7830.0,'Gujrat':11950.0,'Kerala':113.1,\
'Punjab':7152.0, 'Tripura':44.1,'Uttar P.':140168.2}}
df1=pd.DataFrame(iprod)
print(df1)

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Functions min() and max()
min() and max() functions is used to find min and max values from the dataframe set.
The syntax is:
<dataframe>.min(axis=None,skipna=None,numeric_only=None)
<dataframe>.max(axis=None,skipna=None,numeric_only=None)
Here the parameters:
axis = 0 (represents Column (default)), axis=1 (represents row)
skipna = exclude NA/null/NaN values when computing the result
numeric_only = True or False

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Fruits Pulses Rice Wheat
Andhra P. 7830.0 931.0 7452.4 NaN
Gujarat 11950.0 818.0 1930.0 2737.0
Kerala 113.1 1.7 2604.8 NaN
Punjab 7152.0 33.0 11586.2 16440.5
Tripura 44.1 23.2 814.6 0.5
Uttar P. 140169.2 2184.4 13754.0 30056.0

>>>df1.min() >>>df1.max()
Fruits 44.1 Fruits 140169.2
Pulses 1.7 Pulses 2184.4
Rice 814.6 Rice 13754.0
Wheat 0.5 Wheat 30056.0
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
Fruits Pulses Rice Wheat
Andhra P. 7830.0 931.0 7452.4 NaN
Gujarat 11950.0 818.0 1930.0 2737.0
Kerala 113.1 1.7 2604.8 NaN
Punjab 7152.0 33.0 11586.2 16440.5
Tripura 44.1 23.2 814.6 0.5
Uttar P. 140169.2 2184.4 13754.0 30056.0

>>>df1.min(axis=1) >>>df1.max(axis=1)
Andhra P. 931.0 Andhra P. 7830.0
Gujarat 818.0 Gujarat 11950.0
Kerala 1.7 Kerala 2604.8
Punjab 33.0 Punjab 16440.5
Tripura 0.5 Tripura 814.6
Uttar P. 2184.4
Created By: Anand Sir, YouTube Channel: CODEITUP Uttar P. 30056.0
Python Pandas
The DataFrame below represents the highest marks in fives subjects across the four sections.
A B C D
Acct 99 94.0 92 97.0
Eco 90 94.0 92 97.0
Eng 95 89.0 91 89.0
IP 94 NaN 99 95.0
Math 97 100.0 99 NaN
Ques: Write a program to print the maximum marks scored in each subject across all
sections.
import pandas as pd
import numpy as np
print(“Max Marks Scored in Each Subject Section wise is:”)
print(df.max(axis=1)) OR print(df.max(axis=1,skipna=True)
Created By: Anand Sir, YouTube Channel: CODEITUP
Python Pandas
The DataFrame below represents the highest marks in fives subjects across the four sections.
A B C D
Acct 99 94.0 92 97.0
Eco 90 94.0 92 97.0
Eng 95 89.0 91 89.0
IP 94 NaN 99 95.0
Math 97 100.0 99 NaN
Ques: Write a program to print the maximum marks scored by each section.
import pandas as pd
import numpy as np
print(“Max Marks Scored in Each Subject Section wise is:”)
print(df.max())

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Chapter 1 CSV FILES

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
CSV(Comma Separated Values) is a simple file format which stores data in tabular format means either in
database or in spreadsheet. As the name suggest, it is the collection of data which is separated by
comma. A CSV file in Excel will look like tabular data where as when the same file is opened in Notepad, it
will show the same data separated by commas.

Advantages of CSV Format:


• It has a simple, compact way of data storage.
• It is a very common for data interchange.
• It can be opened in popular spreadsheet packages like MS-Excel, Office-Calc etc.
• Nearly all spreadsheet and database support import/export to CSV format.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Creating and Reading CSV File
A CSV is a textfile, so it can be crated and edited using any text editor. All CSV files follow a standard
format, i.e., each column is separated by a delimeiter(such as comma, semicolon,space or a tab) and
each new line indicates a new row.

To create a CSV file just open MS-Excel and create a tabular data as below:

Employee ID Name Desig Salary Mobile


101 Amit Programmer 80000 12345
102 Sumit Soft Eng. 120000 67890
103 Ravi Programmer 85000 12344
104 Anup Senior Programmer 100000 23456
105 Rajeev Asst Team Lead 120000 56790
After typing the information as above you can just save it and while saving give it “Save as type” - “CSV
(Comma delimited)” and thats it..

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Now if you will open this file in Notepad, the same file will look like:

Employee ID,Name,Desig,Salary,Mobile
101,Amit,Programmer,80000,12345
102,Sumit,Soft Eng.,120000,67890
103,Ravi,Programmer,85000,12344
104,Anup,Senior Programmer,100000,23456
105,Rajeev,Asst Team Lead,120000,56790

Here you can find that the same data has been shown by each values are separated by comma(,) and
each row is separated by new line.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Reading from a CSV File to DataFrame

In order to read a CSV file to DataFrame we use read_csv() method. The syntax is:
import pandas as pd
<df>=pd.read_csv(<filepath>)

Practical Implementation
#to open Employee.csv into a Data Frame
import pandas as pd
obj=pd.read_csv(“employee.csv”)
print(obj)

Here, you have to provide the full path of the csv file.

Created By: Anand Sir, YouTube Channel: CODEITUP


Python Pandas
Now if you will open this file in Notepad, the same file will look like:

Employee ID,Name,Desig,Salary,Mobile
101,Amit,Programmer,80000,12345
102,Sumit,Soft Eng.,120000,67890
103,Ravi,Programmer,85000,12344
104,Anup,Senior Programmer,100000,23456
105,Rajeev,Asst Team Lead,120000,56790

Here you can find that the same data has been shown by each values are separated by comma(,) and
each row is separated by new line.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Chapter 3 Data Visualization

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Data visualization is the Graphical Representation of information and data. By using
different visual elements like charts, graphs and maps. Data visualization tool provides easy
way to see and understand the data and related trend/pattern.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
1. There are multiple tools available for data visualization using which we can perform data
visualization.
2. In Python we can use a library called “matplotlib” for data visualization.
3. Python based plotting library “matplotlib” enables us to produce 2D as well as 3D
graphics i.e. charts/graphs.
4. Pyplot interface of matplotlib is used for representing 2D graphs. (In our Syllabus)

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
How to Install matplotlib?
1. Open “Command Prompt” with administrator rights.
2. Here type “python –m pip install matplotlib” and press enter key.
3. In case this command is showing an error it means that you have not set python to
“path” variable. You need to set the path. (For this different set of instructions are there)
4. Note that internet connection is required for installation of matplotlib library.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Pyplot
1. Pyplot is a collection of command type functions that is used for Data Visualization. It is
available inside matplotlib library.
2. Pyplot interface provides many methods for 2D plotting of data using which we can
draw different types of 2D graphs/charts. We can draw different types of graphs/charts
using different pyplot methods i.e. plot(), bar(), pie() etc.
3. Multiple types of charts/graphs can be plotted using pyplot like line chart, bar chart,
pie chart, scattered chart, histogram etc.
4. To use pyplot we have to import matplotlib which can be done by two ways:
1. import matplotlib
2. import matplotlib.pyplot as plt

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart Bar Chart
A line chart or Line Graph is a type of A Bar chart or Bar Graph is a type of
chart which displays information as a chart which displays information as a
series of data points called ‘markers’ series of lines of rectangle with a
connected by straight line segments. height and length.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Pie Chart Histogram
A line chart or Line Graph is a type of A histogram is a graphical display of
chart which a circle is divided into data using bars of different heights. In
sectors that each represents a a histogram, each bar groups
proportion of the whole. numbers into ranges. Taller bar shows
that more data falls into that range.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Chapter 3 Data Visualization
Part 3 | Line Charts

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart
A line chart or Line Graph is a type of chart
which displays information as a series of data
points called ‘markers’ connected by straight
line segments.
Pyplot has plot() function to create a line chart.

The syntax is:


<matplotlib.pyplot>.plot(x-axis, y-axis, color, linewidth,
linestyle or ls, marker, markersize, markeredgecolor)

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart
Pyplot has plot() function to create a line chart.
The syntax is:
<matplotlib.pyplot>.plot(x-axis, y-axis, color, linewidth, linestyle or ls, marker, markersize,
markeredgecolor)

X-axis, Y-axis : Points on X & Y axis in a form of sequence.


color : Color of Line. Should be valid color identified by pyplot
linewidth : Width of line in points (float value)
linestyle or ls : Style of the line (Solid line, dashed line etc)
marker : A symbol denoting the marker style such as ‘o’, ‘*’, ‘+’ etc.
markersize : Marker size in points (float value)
markeredgecolor: Color or marker. Should be valid color identified by pyplot.
Created By: Anand Sir, YouTube Channel: CODEITUP
Data Visualization
Program to draw Line Chart:

import matplotlib.pyplot
x=[2,4,6,8,10]
y=[5,2,6,4,8]
matplotlib.pyplot.plot(x,y)
matplotlib.pyplot.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart
Parameters:
color: This is used to set Color of the line. This color could be any valid color.
markeredgecolor: This is used to sert Color of marker. This color could be any valid color.

Character Color
b blue
g green
r red
m magenta
y yellow
k black
c cyan
w Created By: Anand Sir, YouTube Channel: CODEITUP
white
Data Visualization
Line Chart Line Chart
With only Y-Axis Points With only Y-Axis Points
➢If we given only one list, it will take x axis ➢If we given only one list, it will take x axis
value by default [0,1,2,3,4..] value by default [0,1,2,3,4..]
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
y=[8,5,6,4,8] y=[8,5,6,4,8]
plt.plot(y) plt.plot(y,color=“green” or “g”)
plt.show() plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart Linestyle Attributes
import matplotlib.pyplot as plt 1. ‘solid’ or ‘-’ [Default]
y=[8,5,6,4,8] 2. ‘dashed’ or ‘—’
plt.plot(y,linewidth=10)
3. ‘dashdot’ or ‘-.’
plt.show()
4. ‘dotted’ or “:”

Line Chart
All the attributes can be combined
import matplotlib.pyplot as plt
altogether.
y=[8,5,6,4,8]
plt.plot(y,linestyle=“dotted”)
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart Plot Parameters
import matplotlib.pyplot as plt 1. marker: A symbol denoting the marker
arr=[10,15,20,16,24,30,12] style such as ‘o’, ‘*’, ‘+’ etc.
plt.plot(arr,marker=‘*’,markersize=8, 2. markersize: Marker sie is points (float)
markeredgecolor=‘red’)
3. markeredgecolor: Color of marker.
plot.show()
Should be valid color identified by
pyplot.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Line Chart
Plotting Two or More Graphs on same plot:

from matplotlib import pyplot as plt


arr=[5,10,21,10,25,36]
arr1=[1,3,5,2,4,6]
plt.plot(arr)
plt.plot(arr1)
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Chapter 3 Data Visualization
Part 4 | Bar Chart

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Bar Chart
A diagram in which the numerical values of variable are represented by the height or
length of lines or rectangles.
For the bar chart we will use the bar() function, where we define the position of the bars
on the x axis and their height on the Y axis.
Additionally, we can also configure another characteristics for the char, like width of
the bar, color, among others.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Bar Chart
import matplotlib.pyplot as plt;
#Here both values X and Y are required and both should be of same size
y=[20,30,40]
x=[ 0,1,2]
plt.bar(x,y)
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Bar Chart
bar() syntax:
<matplotlib.pyplot>.bar(x-axis,y-axis,width,color,align)

X Axis – Points on x axis in the form of sequence


Y Axis (Height) – Height or Points on Y Axis in the form of sequence
color – This is used to change the Color of line.
width – Width of bars in the form of scalar values or as a sequence
align – {‘center’,’edge’}, it is optional, default ‘center’

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Bar Chart
import matplotlib.pyplot as plt;
#Here both values X and Y are required and both should be of same size
y=[20,30,40]
x=[ 0,1,2]
plt.bar(x,y, width=1.1)
#if we want we can assign different width to different bars. For this we need to give the width in list
form.
#plt.bar(x,y,width=[1.2,2.0,1.2])
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Bar Chart
Parameters:
color: This is used to set Color of the line. This color could be any valid color.

Character Color
b blue
g green
r red
m magenta
y yellow
k black
c cyan
w white
Created By: Anand Sir, YouTube Channel: CODEITUP
Data Visualization
Bar Chart
import matplotlib.pyplot as plt;
#Here both values X and Y are required and both should be of same size
y=[20,30,40]
x=[ 0,1,2]
plt.bar(x,y,width=[1.2,2.0,1.2],color=‘red’) #it will give all bars red color
plt.bar(x,y,width=[1.2,2.0,1.2],color=[‘red’,’green’,’blue’])
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Bar Chart
Parameters:
Align: This is used to set the alignment of the bar. It has two values: center & edge. By
default align is set to center.
import matplotlib.pyplot as plt;
#Here both values X and Y are required and both should be of same size
y=[20,30,40]
x=[ 0,1,2]
plt.bar(x,y,width=[1.2,2.0,1.2],color=‘red’) #it will give all bars red color
plt.bar(x,y,width=[1.2,2.0,1.2],color=[‘red’,’green’,’blue’],align=‘edge’)
plt.show()
Created By: Anand Sir, YouTube Channel: CODEITUP
Data Visualization
Horizontal Bar Chart (barh())

import matplotlib.pyplot as plt


a=[1,2,3,4,5]
b=[10,20,30,40,50]
plt.barh(a,b)
#Note that here the parameter a is value for
y axis and b is the value for x axis.
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES
Chapter 3 Data Visualization
Part 5 | Histogram

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
A histogram is a graphical display of data using bars of different heights.
In a histogram, each bar groups numbers into ranges. Taller bars show that more data
falls in that range.
hist() function is used for generating histogram in pyplot.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Difference between Bar Char and Histogram
Bar chart represents a single value whereas Histogram represent range of value.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
plt.hist([1,4,7,12,13,15],bins=[1,5,10,15])
# [1,4,7,12,13,15] are values which has to be adjusted
# =[1,5,10,15] is the range
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)

x: Array or sequence of arrays to be plotted on Histogram


bins: an integer or sequence, used to divide the range in the histogram
cumulative: True or False, Default is False
histtype: {‘bar’,’barstacked’,’step’,’stepfilled’}, Default ‘bar’
align: {‘left’,’mid’,’right’} default is ‘mid’
orientation: {‘horizontal’,’vertical’},Default ‘horizontal’

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)

x: Array or sequence of arrays to be plotted on Histogram, we can give a single list or


multiple list and this is the value which will be displayed on the histogram.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
We can also draw multiple histogram together.
import matplotlib.pyplot as plt
a=[2,5,4,6,8,7]
b=[6,5,8,9,4,2]
plt.hist([a,b])
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)
bins: an integer or sequence, used to divide the range in the histogram. If we supply
some value for it, it will use the same as x axis range otherwise it takes the first value and
last value from the list of values and automatically creates the bin.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
plt.hist([1,4,7,12,13,15])
# [1,4,7,12,13,15] are values which has to be adjusted
plt.show()

#This will create a histogram with auto generated bins. That means it will take the first
value as 1 and last value as 15 and will automatically create the range i.e. bins.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
plt.hist([1,4,7,12,13,15],bins=[1,5,10,15])
# [1,4,7,12,13,15] are values which has to be adjusted
# =[1,5,10,15] is the range
plt.show()

#Here we can give both, the values and the bins, so it will take the same.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
a=[2,4,5,3,8,9]
plt.hist(a,bins=5)
plt.show()

#Here we can give number of bins as well. The given number of bins will be there in the
chart.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)
cumulative: True or False, Default is False
Cumulative means the previous data will be added the next bar (previous counting will
be added to the next bar of the histogram.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
a=[2,4,10,22,14,18]
plt.hist(a,bins=[1,10,20),cumulative=True]
plt.show()

#Here we can give number of bins as well.


The given number of bins will be there in the chart.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)
histtype – This is the type of Histogram
1. ‘bar’ – This is the default one.
2. ‘barstacked’ - It is used when providing two or more arrays as data
3. ‘step’ – This generates a lineplot that is bydefault unfilled
4. ‘stepfilled’ – This generates a filled lineplot

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
a=[2,4,10,22,14,18]
b=[5,9,15,20]
plt.hist([a,b],bins=[1,10,20),histtype=‘barstacked’]
plt.show()

#It will show both the bars one upon another with different colors.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
a=[2,4,10,22,14,18]
b=[5,9,15,20]
plt.hist([a,b],bins=[1,10,20),histtype=‘bars’]
plt.show()

#It will show two different bars side by side.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
a=[2,4,10,22,14,18]
b=[5,9,15,20]
plt.hist([a,b],bins=[1,10,20),histtype=‘step’]
plt.show()

#It will show both the bars but just the outlines will be shown.
# It won’t be filled.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Program
import matplotlib.pyplot as plt
a=[2,4,10,22,14,18]
b=[5,9,15,20]
plt.hist([a,b],bins=[1,10,20),histtype=‘stepfilled’]
plt.show()

#It will show both the bars one upon another with same colors.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)
Orientation: This is an optional argument. Here the orientation may be left or right. It is
optional.

Created By: Anand Sir, YouTube Channel: CODEITUP


Data Visualization
Histogram
Syntax
<matplotlib.pyplot>.hist(x,bins=None,Cumulative=False, histtype=‘bar’,align=‘mid’,
orientation=‘vertical’)
align – Sets the alignment of the bars
The values can be left/right/mid.
Program
import matplotlib.pyplot as plt
a=[2,4,10,22,14,18]
b=[5,9,15,20]
plt.hist([a,b],bins=[1,10,20),align=‘left’]
plt.show()

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 1 | Digital Footprint
Created By: Anand Sir, YouTube Channel: CODEITUP
Societal Impact
Digital Footprint

A digital footprint is data that is left behind when user was online and left after
performing his/her work. There are two types of digital footprints:

a. Active Footprint
b. Passive Footprint

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Digital Footprint is broadly divided into two parts:

A. Active Footprint
An Active Digital Footprint is where the user has deliberately shared information
about themselves either by using social media sites or by using websites.

B. Passive Footprint
A Passive Digital Footprint is made when information is collected from the user
without the person knowing this is happening.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Example of Active Digital Footprints

a. Posting on Instagram, Facebook, Twitter & other social media platforms.


b. Filling out online forms i.e. when signing up or receive e-mails or text.
c. Agreeing to install cookies on our device when prompted by the browser.

Examples of Passive Digital Footprints

a. Websites that install cookies in our device without disclosing it to us.


b. Apps and websites that use zeolocation to pinpoint our location.
c. Social Media news channels and advertisers that use our likes, shares and comment
to serve up advertisement based on our interests.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
How Digital Footprint is being used for Marketing Purposes
Digital Footprint are also known as cyber shadow, electronic footprint, or Digital
Shadow. These are generally collected with the help of tracking cookies. These cookies
are created while using popular sites. Whatever, we search is stored in these cookies
with dates and location. These are collected by actual sites when we are visiting that
popular / unknown sites. The respective sites in turn analyze these data and revert back
in the form of advertise later on.
For example: We search for a flight for x location to y location for a date. Next
day if we open search engine, ads automatically pops even if we have booked our
ticket.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Why we should care about managing our Digital Footprint

We should care about managing our Digital Footprint for the following reasons:

a. To protect our reputation


b. To make safe personal information
c. To prevent financial lose
d. To preserve our freedom

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Risk Due to Digital Footprint

a. Privacy Concern
b. Scam
c. Identity Theft
d. Fake Website

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
How to Manage Digital Footprint

1. Do not Enter Name into several search engines.


2. Always use to check privacy settings.
3. Create strong, memorable passwords.
4. Keep all our software up to date.
5. Review our mobile use.
6. Delete useless files

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 2 | Net or Communication Etiquettes

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Net or Communication Etiquettes:

Netiquettes is short form “Internet Etiquettes” or “Communication Etiquettes” over


Internet. It is just like etiquettes – a code of polite behavior in society, netiquette is code
of good behavior on the internet. It includes several aspects of the internet, social
media, email, online chat, web forum, website comments, multiplayer gaming, and
other types of online communications.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Net or Communication Etiquettes

Do

a. Keep Message and post brief


b. Use discretion
c. Protect personal information.
d. Obey copyright law.
e. Help others.
f. Respect other people privacy.
g. Verify fact before reposting.
h. Check message and respond promptly
i. Thanks others who help you online.
j. Show good sportsmanship when playing online games.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Net or Communication Etiquettes

Don’t

a. Posting inflammatory/offensive comments shout


b. Respond to internet trollers
c. Post private or embarrassing image/comments
d. Name-call or express offensive opinions
e. Exclude people or talk behind their back
f. Spam others by sending large amount of unsolicited emails.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 3 | Data Protection

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Data Protection

This refers to the practices, safeguard, and bending rule put in place to protect
our personal information and ensure it remain in control. In short, we should be able to
decide whether or not we want to share some information, who has access to it, for
how long, for what reason and be able to modify some of this information, and more.
Data Protection enable us to protect our data from unauthorized user and safeguard
our privacy.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Consequence of Unprotected Data / Data Breaches

a. Suffer from security breach / attack


b. Physical data loss
c. Hit with a virus
d. Targeted by Hackers
e. Suffer from DDoS (Distributed Denial of Service)
f. Loss of money
g. Intellectual property at risk
h. Damage Down time

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
DDoS (Distributed Denial of Service)

DDos stands for Distributed Denial of Services which is also a type of cyber
attack. It’s main aim is to terminate/stop any online web services, Server etc so that the
user’s of that website/application could not use them.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
How we can protect our personal data online?

a. Through encrypt our data


b. Keep password private
c. Don’t overshare on Social Media Networking sites
d. Use security software
e. Avoid phishing emails.
f. Be wise about wifi.
g. Safely dispose off personal information.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 4 | Intellectual Property

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Intellectual Property (IP)

Intellectual Property is a property created by a person or group of persons using


their own efforts and mind and which is already not available in the public domain.
Examples of IP are an invention relating to a product or any process, a new design, a
literary or artistic work and a trademark (a word, a symbol and / or a logo, etc.)

For Example:
a. A video created by you
b. An idea innovated by you
c. A blog written by you and so on.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Intellectual Property Rights (IPR)

Intellectual Property Right (IPR) is the statutory right granted by the Government,
to the owner(s) of the intellectual property or applicant(s) of an intellectual property
(IP) to exclude others from exploiting the IP. An Intellectual Property is someone’s own
hard work and it must be protected to boost the morale of the creator. IPR gives a
strong support to the creators of IP so that their content can’t be
misused/altered/stolen.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Why should an IP be protected?

✓ IP is an assets and can be used by the owner for commercial gains any manner.
✓ IP owner may intend to stop others from manufacturing and selling products and
services which are dully protected by him.
✓ IP owner can sell and/or license the IP for commercial gains.
✓ IP can be used to establish the goodwill and brand value in the market.
✓ IP can be mention in resumes of it’s creator and thus show competence of the
creator.
✓ PR certificate establishes legal and valid ownership about an intellectual property.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Kinds of IPRs

✓ Patent (to protect technologies - The Patent Act)


✓ Trade Mark (to protect words, signs, logos, labels –The Trade Mark Act)
✓ Design (to protect outer ornamental configuration –The Designs Act)
✓ Geographical Indications (GI) (to protect region specific product –The
Geographical Indications of Goods Act)
✓ Copyright (to protect literary and artistic work –The Copyright Act)

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
IPRs are protected in accordance with the provisions of legislations of a country
specific. In India, IPRs can be protected and monopolized as per the act. Some of
them are

1. The Patent Act, 1970,


2. The Designs Act, 2000,
3. The Trade Mark Act, 1999,
4. The Geographical Indications of Goods Act, 1999,
5. The Copyright Act, 1957,
6. Protection of Integrated Circuits Layout and Designs Act, 2000,
7. Protection of Plant Varieties and Farmers Rights Act, 2001.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 5 | Plagiarism

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Plagiarism

Plagiarism is “the act of presenting the works, ideas, images, sounds, or the
creative expression of others as it is your creation or your own.” The word plagiarism is
derived from the Latin word plagiare, which means to kidnap or abduct.
Simply we can say that “Plagiarism is staling someone’s Intellectual work and
representing it as your own work”.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
What is Plagiarism?

a. Plagiarism is stealing of intellectual property


b. Plagiarism is cheating
c. Plagiarism is an Academic offence
d. Plagiarism is Academic theft

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Act that is considered as Plagiarism

1. Using other author’s work as representing it as yours.


2. Using someone else’s work in incorrect form than intended originally by the
author/creator.
3. Modifying someone’s production like music etc without attributing it’s creator.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
How to avoid plagiarism

1. Use your own ideas


2. Cite the sources-When someone else's ideas are used, always acknowledge the
sources and tell your reader WHERE THE IDEAS ARE FROM.
3. Rewrite other's ideas in your own words
4. Take careful notes
5. Develop your writing skill

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 6 | Open Source Concepts

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Open Source Philosophy
Open Source Software refers to those categories of software/programs
whose licensees do not imposes much conditions. Such software givens us the freedom
to use the software for any purpose, study/modify/redistribute copies of
original/modified programs without any payments.

There are two terms which are confusing. Let’s talk about them first:

a. Free Software
b. Open Source Software

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Free Software

Free Software means the software that is freely accessible and can be
used/modified/copied/distributed without any payments.

Richard Stallman’s definition of Free Software:

1. Freedom to tun the program for any purpose.


2. Freedom to study how the program works and access the source code.
3. Freedom to redistribute copies.
4. Freedom to improve the program and release new version.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Open Source Software

Open Source Software can be freely used but it does not have to be free of
charge. Here he company the company may charge payments for the support and
further developments. Here in Open Source Software the source code is freely
available to the customer.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Freeware
The term freeware is used for software which is available free of cost and which
allows copying and further distribution, but not modifications and it’s source code is
also not available.

Shareware
Shareware is a type of software which is available with the facility to redistribute
the copies with a limitation that after a certain period of time, the license fee should be
paid.
It is not Free and open source as :
a. It’s source code is not available.
b. modifications to the software are not allowed.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Full Forms
1. OSS – Open Source Software
2. FOSS – Free and Open Source Software
3. FLOSS – Free Libre/Livre and Open Source Software
4. GNU – GNU Not Unix
5. FSF – Free Software Foundation
6. OSI – Open Source Initiative
7. W3C – World Wide Consortium
8. VISA – VISA International Service Association

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 7 | Software Licensing

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Software License

The Licenses are permissions given to someone to use a product or someone’s


creation.
Copyright defines the ownership rights. It is nothing but collection of rights to the
creator of a work such as design, song, movie, software etc. A copyright holder can
give licenses to use its work in a specific way.
Copyleft is a license that gives rights opposite the copyright. Copyleft offers
users the right to freely distribute and modify the original work with a condition that all
the modifications/extension will have same copyleft license.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Software Copyright
Software copyright is used by software developers/software
companies/proprietary software companies to prevent the unauthorized copying of
their software. Software Copyright states that no one can use the pirated/copy of the
said software. Free and open source licenses also rely on copyright law to enforce their
terms.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Benefits of Using Licensed Software

a. Using Unlicensed Software Against the Law


b. The Right Software License Can Save our Money
c. We can Receive Around-The-Clock License Support
d. Licensed software provides time to time updates
f. Licensed software promotes the morale of developers

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Open Source License

As per open source initiative “Open Source licenses are licenses that comply with the
Open Source Definition – in brief, they allow software to be freely used, modified, and
shared”.

Broadly used open source licenses are :

1. GNU (General Public License)


2. LGPL (GNU Lesser General Public License)
3. BSD (Berkeley Software Distribution)
4. MIT (Massachusetts Institute of Technology
Least Restrictive Open Source Lincese.
5. Apache License

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Public Domain Software vs. Proprietary Software

Public domain software is free and can be used without restrictions. It is never related to
freeware, free software etc because it is outside the scope of copyright and licensing.

Proprietary software on the other hand, is neither free nor available for public. There is a
license attached to it and the user need to purchase/buy the license.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 8 | Cyber Crime

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Cyber Crime
Any criminal offence that is done by using electronic communications or
information systems, any electronic device, computer, Internet are referred to as Cyber
Crime.
Cybercrime is a generic term for: phishing, credit card frauds, illegal
downloading, industrial espionage, child pornography, cyber bullying, cyber stalking,
cyber terrorism, creation/distribution of viruses, spam and many more.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Cyber Crime
1. Hacking
a. Spoofing
b. Phishing
c. Social Engineering/Pretexting
2. Cyber Trolls and Bullying
a. Cyber Bullying
3. Cyber Stalking
4. Scams
5. Illegal Downloads
6. Child Pornography

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
1. Hacking
While working on internet, we usually enter many sensitive information like our
name, address, credit card details, DOB and many more. These all information are very
confidential information and must not fall into wrong hands.
Hacking refers to gaining unauthorized access to a network or computer or
digital files, with an intention to steal or manipulate data or information or to install
malware. Hackers exploit our computer/network security and employ technique like:
a. spoofing
b. phishing
c. social engineering
etc. to capture user’s personal or financial details.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
a. Spoofing
Spoofing is a type of scam in which a criminal disguises an email address,
display name, phone number, text message, or website URL to convince a target that
they are interacting with a known, trusted source.
Spoofing often involves changing just one letter, number, or symbol of the
communication so that it looks valid at a quick glance. For example, you could receive
an email that appears to be from Netflix using the fake domain name “netffix.com.”

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
b. Phishing

Phishing is the practice of attempting to acquire sensitive information from


individuals over the internet, by means of deception.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
c. Social Engineering/Pretexting
Usually the Hackers poses as a legitimate business or government officials to
obtain our personal information.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
2. Cyber Trolls and Bullying
Cyber trolls refers to a person who knowingly and intentionally posts opposing,
sarcastic, demeaning or insulting comments about something or someone with an
aim of targeting a person online.
The provocation message posted in such a way is called troll.

Cyber Bullying
When someone uses the Internet and various forms of social network to harass,
demean, embarrass, or intimidate someone, it is called Cyber Bullying.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
3. Cyber Stalking
Cyberstalking refers to the use of the internet and other technologies to harass
or stalk another person online, and is potentially a crime in the United States. This
online harassment, which is an extension of cyber bullying and in-person stalking, can
take the form of e-mails, text messages, social media posts.
Basically, these stalkers know their victims and instead of offline stalking, they
use the Internet to stalk.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
4. Scams
Any fraudulent business practice that extracts money from an unsuspecting,
ignorant person is called a scam. Scams which are done online are called Online
Scams.
How to avoid Online Scams:
a. Never enter personal information anywhere, use websites with https protocol.
b. Never reply to mails from unknown or unreliable source.
c. Never click on anonymous links.
d. Ignore “You Won’ emails.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
5. Illegal Downloads
The file which we are downloading from Internet and we don’t have right to
use or download that from the Internet. It is something like you are downloading paid
item free of cost.
Viz. Downloading movie online (illegal as these movie has copyright)

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
6. Child Pornography
Child pornography is any visual of written representation that depict or
advocate sexual activity (Sexual molestation or exploitation) of anyone under the age
of 18.
As per new amendment in Information Technology Bill, Section 67 – “Not only
creating and transmitting obscene material in electronic form but also to browse such
sites is an offence.”

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 9 | Cyber Law and IT Act

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Cyber Law and IT Act
Cyberlaw is a term which refers to all legal and regulatory aspects of Internet
and World Wide Web. In simple words we can say that all the rules and regulations
related to Internet and Information technology comes under Cyberlaw.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
India’s IT Act and IT (Amendment) Act, 2008
In India, cyber laws are enforced through IT Act, 2000 which was notified on 17
October 2000. It is based on the United Nation’s Commission for International Trade
related laws (UNCITRAL) model law.

IT ACT 2000’s prime purpose was to provide legal recognition to electronic


commerce.

This act was amended in December 2008 through IT Amendment Act, 2008.
This enforced new section on cyber terrorism and
Data Protection.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
India’s IT Act and IT (Amendment) Act, 2008
Major amendments of IT ACT (2008) include:
a. Digital Signatures: Authentication of electronic records by digital signatures gets
legal recognition.
b. Electronic Governance: E-Documents get legal recognition.
c. Offences and Penalties: The maximum penalty for any damage to the computers
or computer systems may go upto 1 Crore.
d. Amendments to other laws:
Indian Penal Code, 1860
Indian Evidence Act, 1872
Bankers’ Book Evidence Act, 1891
Reserve Bank of India Act, 1934

were aligned with the IT Act.

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 10 | E-Waste Management

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
E-Waste Management
E-waste stands for Electronic Waste which is also known as e-Scrap or Waste Electrical
and Electronic Equipment(WEEE) which refers to all those devices which are
discarded either electrical or electronic.
Electronic waste may include discarded computers, electronic equipment in
offices, mobile phones, television and refrigerators.
E-waste includes those electronic devices which are destined for reuse, resale,
recycling or disposal.
Now a days, electronic waste is:
a. fastest growing segment of waste.
b. most valuable due to its basic composition.
c. very hazardous if not handled carefully

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
E-Waste Disposal Process
E-waste has been categorized by the government of India under the broad class of
hazardous waste. E-waste consist of metallic and non metallic elements such as
Copper, Aluminium, Gold, Silver, Palladium, Platinum, Nickel, Tin, Lead, Iron, Sulphar,
Phosphorous, Arsenic etc.

E-waste needs to be recycled properly. The recycle and recovery include the
following unit operations:

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
E-waste needs to be recycled properly. The recycle and recovery include the
following unit operations:

a. Dismantling: Removing dangerous substances , removal of easily accessible parts


containing valuable substances.
b. Segregation of ferrous metal, non-ferrous metal and plastic
c. Refurbishment and reuse
d. Recycling/recovery of valuable materials
e. Treatment/disposal of dangerous material and waste.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Benefits of e-Waste Recycle
1. Allows for recovery of valuable precious metals.
2. Protects public health and water quality.
3. Creates Jobs.
4. Saves landfill space

Created By: Anand Sir, YouTube Channel: CODEITUP


INFORMATICS
PRACTICES

Chapter 11 | Societal Impact


Part 11 | Health Concerns with Technology Usages

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Health Concerns with Technology Usage
Technology has improved our lives enormously. But along with this, it has come with
various serous health concerns which includes:
1. Impact on Hearing
2. Impact on Bones and Joints
RSI (Repititive Strain Injury)
3. Eye Problem
4. Sleep issues
5. Mental Health Issues

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact
Internet Addiction
Internet Addiction is a case when someone uses Internet excessively on social media,
blogs, online gaming, porn etc. This impacts the mental health which is termed as
Internet Addiction by doctors.
Person who have Internet addiction exhibit feelings of restlessness, moodiness,
depression, or irritability when attempts are made by the family to cut down use of
Internet.

Created By: Anand Sir, YouTube Channel: CODEITUP


Societal Impact

Created By: Anand Sir, YouTube Channel: CODEITUP

You might also like