Practical List
Practical List
1. Crea on of a Series
Fruits=['Apple','Orange','Banana','Cherries','Water Melon','Pear']
NoofFruitssold=[12,45,67,23,44,33]
Consider the two list given above create a Series from it and do the following
i. Display the no of oranges sold
ii. Display the Cherries,Water Melon and Pear using slicing
iii. Display Apple , Orange , Banana,Cherries using loc
iv. Display Banana , Cherries and Water Melon using iloc
Sample Output:
The no of oranges sold are: 45
Cherries , Water Melon and Pear
Cherries 23
Water Melon 44
Pear 33
dtype: int64
Apple , Orange , Banana,Cherries using loc
Apple 12
Orange 45
Banana 67
Cherries 23
dtype: int64
Banana , Cherries and Water Melon using iloc
Banana 67
Cherries 23
Water Melon 44
dtype: int64
peaches 20
oranges 33
cherries 52
pears 10
kiwi 12
Banana 56
Apple 45
dtype: int64
4. Creation of DataFrames
data = {
'apples': [3, 2, 0, 1],
'oranges': [0, 3, 7, 2]
}
(b) Creation of DataFrames from list of dictionaries
data = [{'Apple': 10, 'Banana': 12},{'Apple': 5, 'Banana': 10, 'Custard Apple ': 20}]
Create a dataframe from the list of dictionaries given above
Create a text file mydata.txt as follows and create a dataframe from it.
Create a file in notepad as shown below and save it as myfile.csv and create a dataframe from it.
5. Display
Create a dataframe as given above and display the no of apples and oranges Lily has
Purchased
6. Iteration
7. Iteration
Create a dataframe as given below Iterate through the dataframe and calculate the grades as per marks
(according to the criteria given below)
Marks Grade
M>=90 A+
M>=70 and M<90 A
M>=60 and Marks<70 B
M>=50 and Marks<60 C
M>=40 and Marks <50 D
M<40 F
Consider a dataframe as given below and write the statements with boolean indexing
Name English Maths
0 Manisha 90 95
1 Anil 32 69
2 Pravin 45 65
3 Shweta 97 55
4 Archana 95 95
5 Paritosh 56 78
Create a dataframe as given above and write statements for the following
i. Display all the records with Red Colour
ii. Display all the records with the shape ‘Square’
iii. Display all the records with price more than 10
Create a da rame as shown above and then save it as a csv file called student_data.csv
Data Visualization
16. Line plot
The table shows the daily earnings of a store for five days.
2. Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case.
3. Write an SQL query to print the first three characters of FIRST_NAME from Worker table using substring.
4. Write an SQL query to find the posi on of the alphabet (‘a’) in the first name from Worker table.(only small
‘a’ )
5. Write an SQL query to find the posi on of the alphabet (‘A’) in the first name from Worker table.(only capital
‘A’ )
6. Write an SQL query to print the FIRST_NAME from Worker table a er removing white spaces from the right
side.
7. Write an SQL query to print the DEPARTMENT from Worker table a er removing white spaces from the le
side.
8. Write an SQL query that fetches the unique values of DEPARTMENT from Worker table and prints its length.
9. Write an SQL query to print details of the Workers whose FIRST_NAME contains ‘a’.(Using instr)
10. Write an SQL query to print details of the Workers who have joined in Feb’2014.(Using Year and
Month functions)
11. Write an SQL query to show only rows with odd Id from Worker table.
21. MySQL-Aggregate Functions
1. Write the Create table command to create the table Empl as shown above
2. Display the number of employees who belong to HR dept
3. Display the minimum Salary
4. Display the maximum Salary
5. Display the total Salary
22. MySQL-Querying and manipulating data using Group by, Having, Order by
1. Display the name of dept and the total salary of each dept
3. Display the dept and total salary of all depts. With total salary less than 100000
5. Display all the depts. And the minimum salary of the dept