0% found this document useful (0 votes)
10 views

PRactical File

The document outlines a series of programming tasks related to data manipulation using Pandas in Python. It includes creating and modifying Series and DataFrames, performing calculations, and managing data storage and retrieval. Each task is followed by an expected output section, indicating the need for coding solutions.

Uploaded by

dilshanahmmad
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)
10 views

PRactical File

The document outlines a series of programming tasks related to data manipulation using Pandas in Python. It includes creating and modifying Series and DataFrames, performing calculations, and managing data storage and retrieval. Each task is followed by an expected output section, indicating the need for coding solutions.

Uploaded by

dilshanahmmad
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/ 42

1.

Write a program to create a pandas series from a dictionary of values and a ndarray

OUTPUT:

OUTPUT:

1
2. Write a program to multiply and divide two Pandas Series.

OUTPUT:

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:

OUTPUT:

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

OUTPUT:

9
9. Write a program to create a Dataframe quarterly sales where each row contains the item
category, item name, and expenditure. Do the following tasks in the dataframe:
a) Display the itemname and expenditure columns
b) Display the rows where expenditure is more than 2500

OUTPUT:

10
10.

11
OUTPUT

12
11. Write a Pandas program to count the number of rows and columns of a DataFrame.

OUTPUT:

13
12. Write a program to import and export data between Pandas and CSV file

OUTPUT:

14
13. Write a Program to create a dataframe emp to hold empno, empname and salary details
of 5 employees and perform the following tasks:
(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.
(c) Remove the column ‘Bonus’

OUTPUT:

15
16
14.

OUTPUT:

17
18
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']

OUTPUT:

19
16.

OUTPUT:

20
21
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.

22
23
18.

24
25
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

OUTPUT:

26
20.

27
OUTPUT:

28
29
DATA MANAGEMENT
21. (a) Create a database school. Inside this database, create a table student with the
appropriate specifications for storing the following data.

Displaying the table:


30
(d) Display all the Nonmedical stream students from the table

31
(e) List the names of those students who are in class 12 sorted by stipend

(f) List all students sorted by AvgMarks in descending order

(g) Display the average stipend of each stream

(h) Display the details of students who scored Avgmarks less than 75 and Grade is B

32
(i) Display the total stipend spent for class 12

(j) List the name and stream of students whose name contains letter ‘a’

(k) List the details of students whose grade is either A or C

(l) Display No, Name and Class of students whose score is in the range 60 to 80

33
(m) Display the different streams in the table

(n) Display the number of students in each stream

(o) List the details of students who are not in the Humanities stream

34
22.

Creating the table:

(b) Insert the given records into the table

35
(c) Display all information about teachers of PGT category

(d) To list the names of female teachers of Hindi Department

(e) To list names, departments and date of hiring of all teachers in ascending order of date of
hiring

(f) To count the number of teachers in English department

36
(g) To list the teachers details whose name starts with letter ‘s’

(h) Display gender wise average salaries

(i) Display total salary of each category

(j) To list the details of teachers who joined in year 1980

(k) Display the name, department and category of teachers whose salary is less than 23000

37
(l) Add a new column Bonus to the table and Compute the Bonus as 10% of Salary

(m) Display the name and department of teachers whose name does not contain letter ‘r’

(n) Display the details of teachers in ascending order of Category, then descending order of
Salary

38
(o) Display the details of teachers whose department is either Art or Science

39
23.

Creating Table:

Inserting values:

40
a) Display the first name, last name and amount of reward for all employees.

b) Display first name and salary of all the employees whose amount is less than 2000.

c) Display the first name and date of reward of those employees who joined on Monday.

41
NO OUTPUT
d) Display sum of salary of those employees whose reward amount is greater than 3000

42

You might also like