Ip Practical File Final
Ip Practical File Final
PRACTICAL RECORD
Date: …………………………………….
3 Create pandas series for term marks and calculate the final marks. 3
Program to create a Series named S1 and display its type, change the Series into a list and
4 display its type , display the elements of the Series which are above 20. 5
6 Create and display a DataFrame from a specified dictionary with index labels. 7
16 Add a column, delete a column, delete a row and rename a column in a dataframe 22
Data Visualization
Create a dataframe to store the school result data, analyses the performance of the students
17 on different parameters, e.g., subject wise or class wise. 24
20 Program to create line chart, bar chart and multiple bar chats 30
Data Management
Output:
1
2. Write a program to multiply and divide two Pandas Series.
Output:
2
3. Three series objects stores the marks of 10 students in three terms. Roll numbers of
students form the index of these Series objects. The three series objects have the
same indexes.
Write a Python Program to calculate the final marks obtained by students as per
following formula :
Final marks = 25% term1 + 25% term2 + 50% term3
Store the final marks of students in another Series object.
Output:
3
4
4. Write a program to create a Series named S1 and display its type. Change the Series
into a list and display its type. Also display the elements of the Series which are above
20.
Output:
5
5.Write a program to change the order of index of a given
series.
Original Data Series:
A1
B2
C3
dtype: int64
Data Series after changing the order of index:
B2
A1
C3
dtype: int64
Output:
6
6. Write a program to create and display a DataFrame from a specified dictionary
with index labels.
Output:
7
7. Write a program to get the first 3 rows and last 4 rows of a given
DataFrame
Output:
8
8. Create a dataframe for examination result and display row labels, column labels, data
types of each column and the dimensions
Outputs:
9
9. Write a program to create a Dataframe quarterly sales where each row contains the item
category, item name, and expenditure.
Outputs:
10
b) Display the rows where expenditure is more than 2500
11
10.
Outputs:
12
a) Display city and favourite_color columns of first, fourth and seventh rows
13
11. Write a Pandas program to count the number of rows and columns of a DataFrame.
Output:
14
12. Write a program to import and export data between Pandas and CSV file.
Outputs:
15
13. Write a Program to create a dataframe emp to hold empno, empname and salary details of 5
employees and perform the following tasks:
Outputs:
16
a) Add a column ‘Bonus’ which is calculated as 5% of salary.
b) Add a column ‘Dept’ between empname and salary columns and populate it with appropriate
values.
17
14.
Outputs:
18
ii. Add a new genre of type ‘Folk Tale' having code as “FT” and 600 number of copies.
19
15. Write a program to select the 'name' and 'score' columns from the following DataFrame.
Also change the score in row ‘d’ to 14.5
Sample DataFrame:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthew',
'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Outputs:
20
21
16.
Outputs:
22
(b) Delete column price
23
Data visualization
17. Write a program to create a dataframe to store the school result data, analyses the
performance of the students on different parameters, e.g., subject wise or class wise.
Outputs:
24
25
18.
Outputs:
26
a) A line chart from the 1990 and 2000 columns of dataframe df1
27
19. Create a Dataframe quarterly_sales with columns Salesman, Sales, Quarter and District.
Write a program to draw a histogram based on monthly sales report for all numeric columns.
Outputs:
28
29
20.
30
Outputs:
31
(b) A bar chart depicting the downloads of the apps
(c) Compute Estdownload sequence that has each download value divided by 1000.
32
21.
(a) Create a database school. Inside this database, create a table student with the appropriate
specifications for storing the following data.
USE school;
Name VARCHAR(50),
Stipend DECIMAL(5,2),
Stream VARCHAR(50),
AvgMark DECIMAL(3,1),
Grade CHAR(1),
Class CHAR(3));
33
INSERT INTO student VALUES
Output:
34
c) Delete the details of ‘Mohan’. Undo the changes. Save the details permanently.
Output:
ROLLBACK;
COMMIT;
(d) Display all the Nonmedical stream students from the table.
Output:
35
(e) List the names of those students who are in class 12 sorted by stipend
Stipend ASC;
Output:
Output:
36
(g) Display the average stipend of each stream
Output:
(h) Display the details of students who scored Avgmarks less than 75 and Grade is B
Output:
like ’12%';
Output:
37
(j) List the name and stream of students whose name contains letter ‘a’
Output:
Output:
(l) Display No, Name and Class of students whose score is in the range 60 to 80
And 80;
38
Output:
Output:
Output:
39
(o) List the details of students who are not in the Humanities stream
Output:
40
22. (a) Create table Teacher in database school with the appropriate specification in order to
store the given data
41
SELECT * FROM Teacher;
Output:
Output:
SELECT Name FROM Teacher WHERE Gender = 'F' AND Department = 'Hindi';
Output:
(e) To list names, departments and date of hiring of all teachers in ascending order of date of
hiring
Output:
42
(f) To count the number of teachers in English department
(g) To list the teachers details whose name starts with letter ’s’
Output:
Output:
Output:
43
Output:
(k) Display the name, department and category of teachers whose salary is less than 23000
SELECT NAME, Department, Category FROM Teacher WHERE Salary < 23000;
Output:
(l) Add a new column Bonus to the table and Compute the Bonus as 10% of Salary
Output:
(m) Display the name and department of teachers whose name does not contain letter ‘r’
SELECT NAME, Department FROM Teacher WHERE Name NOT like ‘%r%’;
Output:
(n) Display the details of teachers in ascending order of Category, then descending order of
Salary
44
SELECT * FROM Teacher ORDER BY Category ASC, Salary DESC;
Output:
(o) Display the details of teachers whose department is either Art or Science
Output:
23. Excellent Consultancy Pvt. Ltd. maintains two tables for all its employees.
45
Write queries for the following:
a) Display the first name, last name and amount of reward for all employees.
Output:
b) Display first name and salary of all the employees whose amount is less than 2000.
FROM Employee
Output:
46
c) Display the first name and date of reward of those employees who joined on Monday.
FROM Employee
Output:
EMPTY SET
d) Display sum of salary of those employees whose reward amount is greater than 3000.
FROM Employee
Output:
47