Coolio Trloa
Coolio Trloa
Coolio Trloa
Write a program to create a pandas series from a dictionary of values and a ndarry.
Input
Output
Question 2:
Write a program to multiply and divide two Pandas Series.
Input
Output
Question 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.
Input
Output
Question 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.
Input
Output
Question 5:
Write a program to change the order of index of a given series.
Original Data Series: A 1
B 2
C 3
dtype: int64
Data Series after changing the order of index
B 2
A 1
C 3
dtype: int64
Output
QUESTION 6:
Write a program to create and display a DataFrame from a specified dictionary with index
labels.
Input
Output
QUESTION 7:
Write a program to get the first 3 rows and last 4 rows of a given DataFrame
Input
Output
QUESTION 8:
Create a dataframe for examination result and display row labels, column labels, data types
of each column and the dimensions
Input
Output
QUESTION 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
Input
Output
Question 10:
Write a program to create a dataframe ‘data’ with the following details:
Output
Question 12:
Write a program to import and export data between Pandas and CSV file.
Importing
Input
Output
Exporting
Input
Output
Question 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’.
Question 14:
Write a program to create dataframe ‘stock’ with the following data:
Input
Output
Question 15:
Write a program to select the 'name' and 'score' columns from the following DataFrame.Also
change the score in row ‘d’ to 11.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']
Input
Output
Question 16:
A DataFrame 'item' has the following columns : pid,pname, price.
QUESTION 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.
Input
Question 18:
Given a dataframe df1 as shown below:
Input
Question 20:
Consider the data given below:
Question 21:
(a) Create table Teacher in database school with the appropriate specification in
order to store the given data
(b) Populate the table with the following records
(c) Delete the details of ‘Mohan’. Undo the changes. Save the details permanently.
(d) Display all the Nonmedical stream students from the table
(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
(i) Display the total stipend spent for class 12
(j) List the name and stream of students whose name contains letter ‘a’
a)
CREATE DATABASE SCHOOL;
CREATE TABLE STUDENT (No INT, Name VARCHAR(25), Stipend DECIMAL, Stream
VARCHAR(30), AvgMark DECIMAL, Grade VARCHAR(5), Class VARCHAR(10), PRIMARY
KEY(No));
b)
INSERT INTO student
-> VALUES(1, 'Karan', 400.00, 'Medical', 78.5, 'B', '12B');
INSERT INTO student
-> VALUES(2, 'Divakar', 450.00, 'Commerce', 89.2, 'A', '11C');
INSERT INTO student
-> VALUES(3, 'Divya', 300.00, 'Commerce', 68.6, 'C', '12C');
INSERT INTO student
-> VALUES(4, 'Arun', 350.00, 'Humanities', 73.1, 'B', '12C');
INSERT INTO student
-> VALUES(5, 'Sabina', 500.00, 'Nonmedical', 90.6, 'A', '11A' );
INSERT INTO student
-> VALUES(6, 'John', 400.00, 'Medical', 75.4, 'B', '12B');
INSERT INTO student
-> VALUES(7, 'Robert' , 250.00, 'Humanites', 64.4, 'C', '11A');
INSERT INTO student
-> VALUES(8, 'Rubina', 450.00, 'Nonmedical', 88.5, 'A', '12A');
INSERT INTO student
-> VALUES(9, 'Vikas', 500.00, 'Nonmedical', 92.0, 'A', '12A');
INSERT INTO student
-> VALUES(10, 'Mohan', 300.00, 'Commerce', 67.5, 'C', '12C');
(c) Delete the details of ‘Mohan’. Undo the changes. Save the details permanently.
(d) Display all the Nonmedical stream students from the table
(e) List the names of those students who are in class 12 sorted by stipend
(j) List the name and stream of students whose name contains letter ‘a’
(o) List the details of students who are not in the Humanities stream
Question 22:
(a) Create table Teacher in database school with the appropriate specification in order to
store the given data
b) Insert the given records into the table
(a) Create table Teacher in database school with the appropriate specification in order to
store the given data
b)
c)
d)
e)
f)
g)
h)
i)
j)
k)
l)
m)
n)
o)