Informatics Practices Class 12
Informatics Practices Class 12
PRACTICES
Python Pandas Chapter 1 Part 1
Series Object
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
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.
import pandas as pd
s5=pd.Series([‘apple’,’boy’,’cat’,’dog’,’egg’])
print(“Series Object”,s5)
import pandas as pd
stu={‘A’:39,’B’:41,’C’:42,’D’:44}
s8=pd.Series(stu)
print(s8)
For Example:
import pandas as pd
import numpy as np
obj3=pd.Series([6.5,np.NaN,2.34])
print(obj3)
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)
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.
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]
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
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())
import pandas as pd
.......
.......
print(trdata.head(100))
print(trdata.tail(5))
import pandas as pd
obj=pd.Series([5,10,15,20,25])
obj=obj+2
print(obj)
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)
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)
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.
import pandas as pd
s11=pd.Series(data=[6700,5600,5000,5200],index=[‘a’,’b’,’c’,’d’])
print(s11[s11>5500])
Dropping elements:
obj2=obj2.drop(‘c’)
Will delete the index c from obj2.
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
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)
Output:
Marketing Sales
name Neha Rohit
age 25 24
sex Female Male
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
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
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
Output: Output:
0 1 2 One Two Three
0 1 2 3 0 1 2 3
1 4 5 6 1 4 5 6
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
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)
Output:
0 1
0 11 12
1 13 14
2 15 16
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)
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)
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’)
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)
>>>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’,:]
===================================
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
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)
>>>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())
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
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.
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.
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.
import matplotlib.pyplot
x=[2,4,6,8,10]
y=[5,2,6,4,8]
matplotlib.pyplot.plot(x,y)
matplotlib.pyplot.show()
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()
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()
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()
#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.
#Here we can give both, the values and the bins, so it will take the same.
#Here we can give number of bins as well. The given number of bins will be there in the
chart.
#It will show both the bars one upon another with different colors.
#It will show both the bars but just the outlines will be shown.
# It won’t be filled.
#It will show both the bars one upon another with same colors.
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
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.
We should care about managing our Digital Footprint for the following reasons:
a. Privacy Concern
b. Scam
c. Identity Theft
d. Fake Website
Do
Don’t
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.
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.
For Example:
a. A video created by you
b. An idea innovated by you
c. A blog written by you and so on.
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.
✓ 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.
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”.
There are two terms which are confusing. Let’s talk about them first:
a. Free Software
b. Open Source Software
Free Software means the software that is freely accessible and can be
used/modified/copied/distributed without any payments.
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.
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.
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”.
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.
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.
This act was amended in December 2008 through IT Amendment Act, 2008.
This enforced new section on cyber terrorism and
Data Protection.
E-waste needs to be recycled properly. The recycle and recovery include the
following unit operations: