IP Record Final-1
IP Record Final-1
INTERNAL EXTERNAL
S.NO DATE CONTENTS PAGE.NO TEACHER’S
INITIAL
1 CREATE A PANDA’S SERIES
FROM A DICTIONARY OF
VALUES AND NDARRAY.
2 GIVEN A SERIES, PRINT ALL
THE ELEMENTS THOSE ARE
ABOVE THE 75TH PERCENT.
3 CREATE A DATAFRAME
QUARTERLY SALES WHERE
EACH ROW CONTAINS THE
ITEM CATEGORY, ITEM NAME,
AND EXPENDITURE. GROUP
THE ROWS BY THE CATEGORY
AND THE PRINT THE TOTAL
EXPENDITURE PER CATEGORY
4 CREATE A DATA FRAME FOR
EXAMINATION RESULT AND
DISPLAY ROW LABELS,
COLUMN LABELS DATA TYPES
OF EACH COLUMN AND THE
DIMENSIONS
5 FILTER OUT ROWS BASED ON
DIFFERENT CRITERIA SUCH AS
DUPLICATE ROWS
6 IMPORTING AND EXPORTING
DATA BETWEEN PANDAS AND
CSV FILE
2
7 GIVEN THE SCHOOL RESULT
DATA, ANALYSES THE
PERFORMANCE OF THE
STUDENTS ON DIFFERENT
PARAMETERS, E.G SUBJECT WISE
OR CLASS WISE
8 FOR THE DATA FRAMES CREATED
ABOVE, ANALYZE, AND PLOT
APPROPRIATE CHARTS WITH
TITLE AND LEGEND
9 TAKEDATA OF YOUR INTEREST
FROM AN OPEN SOURCE,
SUMMARIZE IT AND THEN PLOT IT
USING DIFFERENT PLOTTING
FUNCTIONS OF THE MATPLOTLIB
LIBRARY
10 CREATE A STUDENT TABLE WITH
THE STUDENT ID, NAME, AND
MARKS AS ATTRIBUTES WHERE
THE STUDENT ID IS THE PRIMARY
KEY
11 INSERT THE DETAILS OF A NEW
STUDENT IN THE ABOVE TABLE
12 DELETE THE DETAILS OF A
STUDENT IN THE ABOVE TABLE
13 USE THE SELECT COMMAND TO
GET THE DETAILS OF THE
STUDENTS WITH MARKS MORE
THAN 80
14 FIND THE MIN, MAX, SUM AND
AVERAGE OF THE MARKS IN A
STUDENT MARKS TABLE.
15 FIND THETOTAL NUMBER OF
CUSTOMERS FROM EACH
COUNTRY IN THE TABLE (customer
ID, customer NAME, country) USING
GROUP BY.
16 WRITE A SQL QUERY TO ORDER
THE (student ID, marks) TABLE IN
DESCENDING ORDER OF THE
MARKS.
3
DATA HANDLING
4
1. Create a panda’s series from a dictionary of values and
ndarray
AIM
To develop a python program to create series from a dictionary of values
SOURCE CODE
import pandas as pd
import numpy as np
Arr=np.array(['a','b','c','d','e'])
Ser1=pd.Series(Arr)
Arr2=np.arange(10)
Ser2=pd.Series(Arr2)
dict={'A':10,'B':20,'C':30,'D':40,'E':50}
Ser3=pd.Series(dict)
print(Ser1)
print(Ser2)
print(Ser3)
5
OUTPUT
0 a
1 b
2 c
3 d
4 e
dtype: object
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
dtype: int32
A 10
B 20
C 30
D 40
E 50
dtype: int64
6
RESULT
The program has been executed successfully and output verified.
7
2.Given a Series, print all the elements those are above the 75th
percent
AIM
To develop a python program to create print all the elements those are above the
75th percentile
SOURCE CODE
import pandas as pd
import numpy as np
A=np.array([11,12,13,14,15,16])
S=pd.Series(A)
res=S.quantile(q=0.75)
print(S)
print(res)
print(S[S>res])
8
OUTPUT
0 11
1 12
2 13
3 14
4 15
5 16
dtype: int32
14.75
4 15
5 16
dtype: int32
RESULT
The program has been executed successfully and output verified.
9
3.Create a dataframe quarterly sales where each row contains
group the rows by the category and the print the total
expenditure per category the item category, item name, and
expenditure
AIM
To develop a python program to create a dataframe and to group the rows of
dataframe and print the total expenditure per category
SOURCE CODE
import pandas as pd
import numpy as np
dic={'itemcategory':['car','AC','Fridge','Washing Machine'],\
'itemname':['Ford','York','Wirlpool','IBM'],\
'Expenditure':[900000,30000,20000,15000]}
QuaterSales=pd.DataFrame(dic)
print(QuaterSales)
qs=QuaterSales.groupby('itemcategory')
print(qs['itemcategory','Expenditure'].sum())
10
OUTPUT
itemcategory itemname Expenditure
1 AC York 30000
Expenditure
itemcategory
AC 30000
Fridge 20000
car 900000
RESULT
The program has been executed successfully and output verified.
11
4.Create a data frame for examination result and display row
labels, column labels data types of each column and the
dimensions
AIM
To develop a python program to create a data frame for examination result and
display row labels, column labels data types of each column and the dimensions
SOURCE CODE
import pandas as pd
import numpy as np
Value1=['I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII']
Value2=np.arange(89,101)
dic={'Class':Value1,'Percentage':Value2}
Result=pd.DataFrame(dic)
print(Result)
print()
print(Result.index)
print()
print("column of Dataframe:")
print(Result.columns)
print()
print("Datatypes of Dataframe")
print(Result.dtypes)
print()
print("Dimensions of Dataframe")
12
print(Result.ndim)
13
OUTPUT
Class Percentage
0 I 89
1 II 90
2 III 91
3 IV 92
4 V 93
5 VI 94
6 VII 95
7 VIII 96
8 IX 97
9 X 98
10 XI 99
11 XII 100
column of Dataframe:
Datatypes of Dataframe
Class object
Percentage int32
dtype: object
Dimensions of Dataframe
14
RESULT
The program has been executed successfully and output verified
15
5.Filter out rows based on different criteria such as duplicate
rows
AIM
To develop a python program to Filter out rows based on different criteria such
as duplicate rows
SOURCE CODE
import pandas as pd
dic={'Name':['Sam','John','Peter','Sam','Jenni','Robin','John','Peter'],\
'Marks':[95,96,94,95,92,91,96,94]}
Df=pd.DataFrame(dic)
print("Original Dataframe")
print(Df)
duplicaterow=Df[Df.duplicated(keep=False)]
print(duplicaterow)
16
OUTPUT
Original Dataframe
Name Marks
0 Sam 95
1 John 96
2 Peter 94
3 Sam 95
4 Jenni 92
5 Robin 91
6 John 96
7 Peter 94
Name Marks
0 Sam 95
1 John 96
2 Peter 94
3 Sam 95
6 John 96
7 Peter 94
RESULT
The program has been executed successfully and output verified.
17
6.Importing and exporting data between pandas and CSV file
AIM
To develop a python program to import and export data between pandas and CSV
file
SOURCE CODE
# importing data from CSV file
import pandas as pd
df=pd.read_csv('C:\\Users\\Shivani\\Documents\\IP\\addresses.csv')
print(df)
Dic={'Name':['Sam','John','Peter','Robin','Jenni'],'Marks':[94,95,96,97,98]}
df=pd.DataFrame(Dic)
df.to_csv('C:\\Users\\Shivani\\Documents\\IP\\Dataframe.csv')
18
OUTPUT
RESULT
The program has been executed successfully and output verified.
19
DATA VISUALISATION
20
7.Given the school result data, analyzes the performance of the
students on different parameters, e.g subject wise or class wise
AIM
To develop a python program to analyze the performance of the students on
different parameters
SOURCE CODE
import matplotlib.pyplot as plt
Subject=['IP','Physics','Chemistry','Biology','English']
Percentage=[99,98,97,96,95]
plt.bar(Subject,Percentage,color='pink',width=0.5)
plt.xlabel('Subject Name')
plt.ylabel('Pass Percentage')
plt.show()
21
OUTPUT
RESULT
The program has been executed successfully and output verified.
22
8.FOR THE DATA FRAMES CREATED ABOVE, ANALYZE,
AND PLOT APPROPRIATE CHARTS WITH TITLE AND
LEGEND
AIM
To develop a python program to create dataframe and plot appropriate charts with
title and legend
SOURCE CODE
import matplotlib.pyplot as plt
Subject=['IP','Accounts','Economics','Business Studies','English']
Student1=[99,98,97,96,95]
Student2=[97,96,95,94,93]
Student3=[89,88,87,86,85]
plt.plot(Subject,Student1,marker='+',markeredgecolor='red',label='rank1')
plt.plot(Subject,Student2,marker='+',markeredgecolor='red',label='rank2')
plt.plot(Subject,Student3,marker='+',markeredgecolor='red',label='rank3')
plt.xlabel('Subject Name')
plt.ylabel('Marks')
plt.legend(loc='upper right')
plt.show()
23
OUTPUT
RESULT
The program has been executed successfully and output verified.
24
9. Take data of your interest from an open source, summarize it
and then plot it using different plotting functions of the
Matplotlib library
AIM
To develop a python program to take data of your interest from an open source,
summarize it and then plot it using different plotting functions of the Matplotlib
library
SOURCE CODE
import pandas as pd
df=pd.read_csv('C:\\Users\\Shivani\\Documents\\IP\\industry-2018-census-
csv.csv')
print(df)
Code=(df['Code'].head(6))
Industry=(df['Industry'].head(6))
plt.bar(Code,Industry)
plt.title("Industry Census")
plt.show()
25
OUTPUT
Code ...
Employed_census_usually_resident_population_count_aged_15_years_and_ove
r
2 A011300 ... 66
26
RESULT
The program has been executed successfully and output verified.
27
DATA MANAGEMENT
28
10.
a)Write MYSQL query to create a database with name school
b) Create a student table with the student id, name, and marks as
attributes where the student id is the primary key
29
11. Insert the details of a new student in the above table
30
13.Use the select command to get the details of the students with
marks more than 80
14.
a)SQL query to find the minimum marks in the student table
31
c)SQL query to find the sum of marks in the student table
32
15. Find the total number of customers from each country in the
table(customer ID, customer Name, country) using group by
33
16. Write a SQL query to order the (student ID, marks) table in
descending order of the table
34