├── .github
└── .keep
├── Solution
├── salary.csv
├── student_travel.csv
├── Solution Lab-1.txt
├── Solution Lab-4.ipynb
├── Solution Lab-2.txt
├── Solution Lab-3.ipynb
└── Solution Lab-5.ipynb
├── 2. Panda
├── Lab-3.md
├── Lab-4.md
└── Lab-5.md
├── README.md
├── Practise
├── Set-1.md
├── Set-3.md
└── Set-2.md
├── 1. SQLITE
├── Lab-2.md
└── Lab-1.md
└── CSV
└── Automobile_data.csv
/.github/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Solution/salary.csv:
--------------------------------------------------------------------------------
1 | Empid,Empname,Department,Experience,Salary
2 | 1,ABC,BCA,4 Years,40000
3 | 2,DEF,BBA,3 Years,30000
4 | 3,GHI,MCA,2 Years,20000
5 | 4,JKL,MBA,3 Years,30000
6 | 5,MNO,MCA,5 Years,50000
7 | 6,PQR,BCA,6 Years,60000
8 | 7,XYZ,MBA,4 Years,40000
9 |
--------------------------------------------------------------------------------
/2. Panda/Lab-3.md:
--------------------------------------------------------------------------------
1 | Use READER and WRITER object to write and read data in following file “Salary.csv”.
2 |
3 | | Empid | Empname | Department | Experience | Salary |
4 | |-------|---------|------------|------------|--------|
5 |
6 | Perform following operation.
7 |
8 | 1. Write 5 records using writer object in file.
9 | 2. Read file using reader object and print file in proper format.
10 | 3. Append 2 record into file and display it.
11 | 4. Read data from file and print total salary of “BCA” department.
12 | 5. Read file using PANDA library and display records.
13 |
--------------------------------------------------------------------------------
/2. Panda/Lab-4.md:
--------------------------------------------------------------------------------
1 | Use of Dataframe and creating Dataframe from List, Dictionary and CSVfile. (Use Pandas library)
2 |
3 | 1. Create a list consists of ten names. Use the list to store the list elements in DataFrame. Display the created dataframe.
4 |
5 |
6 | 2. Create DataFrame from Dictionary which is consists of lists. Create following dictionary consists of three keys and each of them contain corresponding list of values.
7 | d = {'Student’: ['Rutvik', 'Pankti', 'Evaan', 'Dhyan'],
8 | 'City': ['Pune', 'Delhi', 'Surat', 'Houston'],
9 | 'Age': [22, 16, 5, 13]}
10 |
11 | 3. Store above dictionary in dataframe and display the created dataframe.
12 |
--------------------------------------------------------------------------------
/Solution/student_travel.csv:
--------------------------------------------------------------------------------
1 | SID,COURSE,SNAME,CITY,TRAVEL_BY,TRAVEL_EXPENSE
2 | 1,BCA,LAXMAN,SURAT,BIKE,50
3 | 2,BCA,XMAN,BARDOLI,BUS,25
4 | 3,BCA,AXMAN,VESU,CAR,100
5 | 4,BCA,LAMAN,SURAT,CAR,100
6 | 5,BCA,AMAN,BARDOLI,BUS,25
7 | 6,BCA,CHMAN,VESU,CAR,100
8 | 7,BCA,MAN,BARDOLI,BUS,20
9 | 8,BCA,ABC,VESU,CAR,100
10 | 9,BCA,XYZ,SURAT,BUS,20
11 | 10,BCA,MNO,BARDOLI,BIKE,50
12 | 11,BCA,CDN,VESU,BIKE,50
13 | 12,BBA,SRM,BARDOLI,BUS,20
14 | 13,"",OM,BARDOLI,BIKE,50
15 | 14,BBA,SAI,SURAT,BUS,20
16 | 15,BCA,RAMA,VESU,CAR,100
17 | 16,BCA,AYUSH,BARDOLI,BUS,40
18 | 17,BCA,MEET,"",BIKE,10
19 | 18,"",DEV,SURAT,BUS,500
20 | 19,BBA,SMIT,BARDOLI,CAR,70
21 | 20,BCA,ANZAR,BARDOLI,BUS,30
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PYTHON-JOURNAL
2 | This repo is created for subject "Database Handling Using Python" Subject. List out Practical Exercise for students.
3 |
4 | Students submits their lab practical work and put comments on any query as well as help their peer by commenting on their query.
5 |
6 | Contain question regarding PANDA and Data Visualization with SQLite and CSV file.
7 |
8 | ## HOW TO SUBMIT YOUR WORK
9 |
10 | Create "Solution" folder
11 |
12 | Add your .ipynb file on your "Solution" Folder. Give your file name as Solution-1, Solution-2, .... in your
13 |
14 | ## SQLITE
15 |
16 | This folder contain 2 lab file "lab-1.md" and "lab-2.md". Apply your knowledge and create table with constraints, Add some records and perform CRUD opeartion.
17 |
18 | ## Panda
19 |
20 | This folder contain 3 lab regarding work with databses.
21 |
22 | First lab "Lab-3" regarding create file using reader and writer object.
23 |
24 | Second lab "Lab-4" regarding create .csv file using disctiory and list.
25 |
26 | Third lab "Lab-5" regarding Data Analysis using Python by create database in sqlite and import it into python csv file.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Practise/Set-1.md:
--------------------------------------------------------------------------------
1 | Create “ITEMS” table into SQLite database with appropriate constraints.
2 | Enter empty value also in some records.
3 |
4 | | ITEM_ID | COMPANY | ITEM_NAME | YEAR | SALES_QTY | TOTAL |
5 | |---------|---------|-----------|------|-----------|-------|
6 |
7 |
8 | Create Python script to perform following task.
9 | 1. Add 20 records in table. [ Read all question first before add record.]
10 | 2. Export data into csv file and read into Dataframe.
11 | 3. Name the column who has missing value.
12 | 4. Display item rows between 3th to 7th row.
13 | 5. Using data frame display item name and whose Sales_qty is between 1000 to 5000.
14 | 6. Display item whose price is minimum, maximum.
15 | 7. Sort the data according to item name wise.
16 | 8. Display last 6 rows.
17 | 9. Group items based on company.
18 | 10. Display item_name and Sales_Qty columns data only.
19 | 11. Display item_name,Company and Sales_Qty from record 11 to 15.
20 | 12. Display item whose total is highest.
21 | 13. Count the number of item of each company.
22 | 14. Draw a chart to display 5 most sellable item.
23 | 15. Draw a chart to display 5 most sellable item year wise growth.
24 |
--------------------------------------------------------------------------------
/Practise/Set-3.md:
--------------------------------------------------------------------------------
1 | Create “students” table into SQLite database with appropriate constraints.
2 | Enter empty value also in some records. [ department = BBA,BCA ]
3 |
4 | | ID | NAME | DEPARTMENT | SEMESTER | TOTAL_MARKS | GENDER |
5 | |----|------|------------|----------|-------------|--------|
6 |
7 | Create Python script to perform following task.
8 |
9 | 1. Add 20 to 30 records in table. [ Read all question first before add record.]
10 | 2. Export data into csv file and read into Dataframe.
11 | 3. Display total number of row in dataset.
12 | 4. Name only those columns with total who have missing value.
13 | 5. Display first 10 row data.
14 | 6. Display only ID, Name and Gender of last 10 records.
15 | 7. Display record where sem = 1 and Department = “BCA”
16 | 8. Display record from 12 to 17.
17 | 9. Display semester = 3 student details of each Department
18 | 10. Draw chart to show male and female student of each department.
19 | 11. Add column “Percentage” by calculating from “TotalMarks”
20 | 12. Sort the data according to Name in same dataset.
21 | 13. Grouping data semester wise and show in ascending order of “percentage”.
22 | 14. Display the statistics of dataset.
23 |
--------------------------------------------------------------------------------
/1. SQLITE/Lab-2.md:
--------------------------------------------------------------------------------
1 | Create the below three tables along with key constraints and Write an Insert script for insertion of rows with substitution variables and insert appropriate data.
2 |
3 | **STUDENT (rollno, name, class, birthdate)**
4 |
5 | **COURSE (courseno, coursename, max_marks, pass_marks)**
6 |
7 | **SC (rollno, courseno, marks)**
8 |
9 | Note: use ‘FY, SY, TY’ as class in STUDENT table.
10 |
11 | 1. Display details of student who takes ‘Database Management System’ course.
12 | 2. Display the names of students who have scored more than 70% in Computer
13 | Networks and have not failed in any subject.
14 | 3. Display the average marks obtained by each student.
15 | 4. Select all courses where passing marks are more than 30% of average maximum
16 | mark.
17 | 5. Display all course name.
18 | 6. Display the student details who have secure 1 st rank in ‘Computer Network’
19 | course.
20 | 7. Display all SY student list along with course name.
21 | 8. Display the average marks obtained by each student.
22 | 9. Write a trigger which does not allow deletion of student whose pass_mark is
23 | greater than 35.
24 | 10. Write a trigger which does not allow insertion / updating student whose max-
25 | marks more than 100 and less than 0.
26 |
--------------------------------------------------------------------------------
/2. Panda/Lab-5.md:
--------------------------------------------------------------------------------
1 | Create “student_travel” table into SQLite database with appropriate constraints. Add at least 20 records. Travel by [Bus, Bike, Car].
2 |
3 | Enter empty value also in some records. Repeat value in city name and Travel by column.
4 |
5 | | SID | COURSE | SNAME | CITY | TRAVEL BY | TRAVEL EXPENSE |
6 | |-----|--------|-------|------|-----------|----------------|
7 |
8 | **Create Python script to perform following task.**
9 |
10 | 1. Export data into csv file and read into Dataframe.
11 | 2. Display information of dataframe. Name the column who has missing value.
12 | 3. Replace missing value by mean of that column.
13 | 4. Print first two records only.
14 | 5. Print all record except last 5 records.
15 | 6. Print all record except first 10 records.
16 | 7. Group student based on city name.
17 | 8. Sort records based on Travel by column.
18 | 9. Display those records who travel from “Bardoli” in “Bike”
19 | 10. How many students travel by bus, bike and car?
20 | 11. Display only city name. [ don’t repeat city name ].
21 | 12. Display SNAME and TRAVEL BY columns data only.
22 | 13. Display those record where students are from “BBA” coming in “Car” and “Expense < 500”.
23 | 14. Display records from 5 to 9.
24 | 15. Display student name and city of “BCA” department from records 11 to 15.
25 |
26 |
--------------------------------------------------------------------------------
/Practise/Set-2.md:
--------------------------------------------------------------------------------
1 | Create “online_sales” table into SQLite database with appropriate constraints.
2 | Enter empty value also in some records.
3 |
4 | | INVOICE_NO | CUSTOMER_ID | DESCRIPTION | ORDER_QTY | INVOICE_DATE | PRICE | COUNTRY |
5 | |------------|-------------|-------------|-----------|--------------|-------|---------|
6 |
7 | Create Python script to perform following task.
8 |
9 | 1. Add 20 records in table. [ Read all question first before add record.]
10 | 2. Export data into csv file and read into Dataframe.
11 | 3. Name only those columns with total who have missing value.
12 | 4. Display first 10 row data.
13 | 5. Display only invoice no, description & country (from which order).
14 | 6. Display record where item price > 200 and order_qty >5.
15 | 7. Display statistics of numerical values of dataset.
16 | 8. Draw chart to show top 3 country that have most “Quantity” order.
17 | 9. Add column “revenue” by calculating from “qty” and “price”
18 | 10. Sort the data according to description in same dataset.
19 | 11. Display record from 12.
20 | 12. Grouping data country wise and show its total revenue.
21 | 13. Display country name who generates more revenue.
22 | 14. Display total number of orders of each country in descending order
23 | 15. Draw a chart to display top 3 country revenue growth per month.
24 |
--------------------------------------------------------------------------------
/1. SQLITE/Lab-1.md:
--------------------------------------------------------------------------------
1 | Create the below tables along with key constraints and Write an Insert script for
2 | insertion of rows with substitution variables and insert appropriate data.
3 | DEPARTMENT (dept_no, dept_name, location)
4 |
5 | | DEPT_NO | DEPT_NAME | LOCATION |
6 | |---------|------------|-----------|
7 | | 1 | Sales | Delhi |
8 | | 2 | Production | Mumbai |
9 | | 3 | IT | Hyderabad |
10 | | 4 | Marketing | Ahmadabad |
11 | | 5 | Analysis | Surat |
12 | | 6 | BCA | MP |
13 | | 7 | BBA | Baroda |
14 |
15 | EMPLOYEE (emp_id, emp_name, gender, dept_no, address, designation, salary,
16 | experience, email)
17 |
18 | 1. Display all Department belonging to location ‘Surat’.
19 | 2. List all department name statring with ‘A’.
20 | 3. List all departments whose number is between 1 and 100.
21 | 4. Delete ‘TRG’ department.
22 | 5. Change department name ‘BBA’ to ‘IT’.
23 | 6. Update the location whose dept_name second letter is ‘a’.
24 | 7. Display data whose location is ‘Baroda’, ‘Surat’ and ‘Ahemdabad’.
25 | 8. Display data who are not from ‘sales’ and ‘marketing’ department.
26 | 9. List all records of each table in ascending order.
27 | 10. Display female employee list.
28 | 11. Display all record order by emp_name.
29 | 12. Find the names of the employee who has salary less than 5000 and greater than
30 | 2000.
31 | 13. Display the names and the designation of all female employee in descending
32 | order.
33 | 14. Display the names of all the employees who names starts with ‘A’ ends with ‘A’.
34 | 15. Find the name of employee and salary for those who had obtain minimum
35 | salary.
36 | 16. Add 10% raise in salary of all employees whose department is ‘IT’.
37 | 17. List names of employees who are fresher’s (less than 1 year of experience).
38 | 18. List department wise names of employees who has more than 5 years of
39 | experience.
40 | 19. List department having no employees.
41 | 20. Delete the employee whose salary is less than 10000.
42 |
--------------------------------------------------------------------------------
/CSV/Automobile_data.csv:
--------------------------------------------------------------------------------
1 | index,company,body-style,wheel-base,length,engine-type,num-of-cylinders,horsepower,average-mileage,price
2 | 0,alfa-romero,convertible,88.6,168.8,dohc,four,111,21,13495
3 | 1,alfa-romero,convertible,88.6,168.8,dohc,four,111,21,16500
4 | 2,alfa-romero,hatchback,94.5,171.2,ohcv,six,154,19,16500
5 | 3,audi,sedan,99.8,176.6,ohc,four,102,24,13950
6 | 4,audi,sedan,99.4,176.6,ohc,five,115,18,17450
7 | 5,audi,sedan,99.8,177.3,ohc,five,110,19,15250
8 | 6,audi,wagon,105.8,192.7,ohc,five,110,19,18920
9 | 9,bmw,sedan,101.2,176.8,ohc,four,101,23,16430
10 | 10,bmw,sedan,101.2,176.8,ohc,four,101,23,16925
11 | 11,bmw,sedan,101.2,176.8,ohc,six,121,21,20970
12 | 13,bmw,sedan,103.5,189,ohc,six,182,16,30760
13 | 14,bmw,sedan,103.5,193.8,ohc,six,182,16,41315
14 | 15,bmw,sedan,110,197,ohc,six,182,15,36880
15 | 16,chevrolet,hatchback,88.4,141.1,l,three,48,47,5151
16 | 17,chevrolet,hatchback,94.5,155.9,ohc,four,70,38,6295
17 | 18,chevrolet,sedan,94.5,158.8,ohc,four,70,38,6575
18 | 19,dodge,hatchback,93.7,157.3,ohc,four,68,31,6377
19 | 20,dodge,hatchback,93.7,157.3,ohc,four,68,31,6229
20 | 27,honda,wagon,96.5,157.1,ohc,four,76,30,7295
21 | 28,honda,sedan,96.5,175.4,ohc,four,101,24,12945
22 | 29,honda,sedan,96.5,169.1,ohc,four,100,25,10345
23 | 30,isuzu,sedan,94.3,170.7,ohc,four,78,24,6785
24 | 31,isuzu,sedan,94.5,155.9,ohc,four,70,38,
25 | 32,isuzu,sedan,94.5,155.9,ohc,four,70,38,
26 | 33,jaguar,sedan,113,199.6,dohc,six,176,15,32250
27 | 34,jaguar,sedan,113,199.6,dohc,six,176,15,35550
28 | 35,jaguar,sedan,102,191.7,ohcv,twelve,262,13,36000
29 | 36,mazda,hatchback,93.1,159.1,ohc,four,68,30,5195
30 | 37,mazda,hatchback,93.1,159.1,ohc,four,68,31,6095
31 | 38,mazda,hatchback,93.1,159.1,ohc,four,68,31,6795
32 | 39,mazda,hatchback,95.3,169,rotor,two,101,17,11845
33 | 43,mazda,sedan,104.9,175,ohc,four,72,31,18344
34 | 44,mercedes-benz,sedan,110,190.9,ohc,five,123,22,25552
35 | 45,mercedes-benz,wagon,110,190.9,ohc,five,123,22,28248
36 | 46,mercedes-benz,sedan,120.9,208.1,ohcv,eight,184,14,40960
37 | 47,mercedes-benz,hardtop,112,199.2,ohcv,eight,184,14,45400
38 | 49,mitsubishi,hatchback,93.7,157.3,ohc,four,68,37,5389
39 | 50,mitsubishi,hatchback,93.7,157.3,ohc,four,68,31,6189
40 | 51,mitsubishi,sedan,96.3,172.4,ohc,four,88,25,6989
41 | 52,mitsubishi,sedan,96.3,172.4,ohc,four,88,25,8189
42 | 53,nissan,sedan,94.5,165.3,ohc,four,55,45,7099
43 | 54,nissan,sedan,94.5,165.3,ohc,four,69,31,6649
44 | 55,nissan,sedan,94.5,165.3,ohc,four,69,31,6849
45 | 56,nissan,wagon,94.5,170.2,ohc,four,69,31,7349
46 | 57,nissan,sedan,100.4,184.6,ohcv,six,152,19,13499
47 | 61,porsche,hardtop,89.5,168.9,ohcf,six,207,17,34028
48 | 62,porsche,convertible,89.5,168.9,ohcf,six,207,17,37028
49 | 63,porsche,hatchback,98.4,175.7,dohcv,eight,288,17,
50 | 66,toyota,hatchback,95.7,158.7,ohc,four,62,35,5348
51 | 67,toyota,hatchback,95.7,158.7,ohc,four,62,31,6338
52 | 68,toyota,hatchback,95.7,158.7,ohc,four,62,31,6488
53 | 69,toyota,wagon,95.7,169.7,ohc,four,62,31,6918
54 | 70,toyota,wagon,95.7,169.7,ohc,four,62,27,7898
55 | 71,toyota,wagon,95.7,169.7,ohc,four,62,27,8778
56 | 79,toyota,wagon,104.5,187.8,dohc,six,156,19,15750
57 | 80,volkswagen,sedan,97.3,171.7,ohc,four,52,37,7775
58 | 81,volkswagen,sedan,97.3,171.7,ohc,four,85,27,7975
59 | 82,volkswagen,sedan,97.3,171.7,ohc,four,52,37,7995
60 | 86,volkswagen,sedan,97.3,171.7,ohc,four,100,26,9995
61 | 87,volvo,sedan,104.3,188.8,ohc,four,114,23,12940
62 | 88,volvo,wagon,104.3,188.8,ohc,four,114,23,13415
63 |
--------------------------------------------------------------------------------
/Solution/Solution Lab-1.txt:
--------------------------------------------------------------------------------
1 |
2 | CREATE TABLE DEPARTMENT
3 | (
4 | DEPT_NO INT PRIMARY KEY,
5 | DEPT_NAME VARCHAR2(15) NOT NULL,
6 | LOCATION VARCHAR2(15)
7 | );
8 |
9 |
10 | INSERT INTO DEPARTMENT
11 | VALUES(1,'SALES','DELHI');
12 |
13 | INSERT INTO DEPARTMENT
14 | VALUES(2,'PRODUCTION','MUMBAI');
15 |
16 | INSERT INTO DEPARTMENT
17 | VALUES(3,'IT','HYDERABAD');
18 |
19 | INSERT INTO DEPARTMENT
20 | VALUES(4,'MARKETING','AHMADABAD');
21 |
22 | INSERT INTO DEPARTMENT
23 | VALUES(5,'ANALYSIS','SURAT');
24 |
25 | INSERT INTO DEPARTMENT
26 | VALUES(6,'BCA','MP');
27 |
28 | INSERT INTO DEPARTMENT
29 | VALUES(7,'BBA','BARODA');
30 |
31 | CREATE TABLE EMPLOYEE
32 | (
33 | EMP_ID INT PRIMARY KEY,
34 | EMP_NAME VARCHAR2(20),
35 | GENDER CHAR(6),
36 | DEPT_NO REFERENCES DEPARTMENT(DEPT_NO),
37 | ADDRESS TEXT,
38 | DESIGNATION VARCHAR2(15),
39 | SALARY INT,
40 | EXPERIENCE REAL,
41 | EMAIL VARCHAR(30)
42 | );
43 |
44 | INSERT INTO EMPLOYEE
45 | VALUES(101,'RAJ','MALE',3,'SURAT','CEO',30000,6,'raj121@gmail.com');
46 |
47 | INSERT INTO EMPLOYEE
48 | VALUES(102,'SUMIT','MALE',3,'BARDOLI','CFO',35000,8,'sumit21@gmail.com');
49 |
50 | INSERT INTO EMPLOYEE
51 | VALUES(103,'SHAHIL','MALE',2,'MUMBAI','MANAGER',25000,10,'shahil33@gmail.com');
52 |
53 | INSERT INTO EMPLOYEE
54 | VALUES(104,'DIYA','FEMALE',2,'AHMADABAD','MD',38000,0.5,'diya44@gmail.com');
55 |
56 | INSERT INTO EMPLOYEE
57 | VALUES(105,'RIYA','FEMALE',6,'BARODA','HOD',40000,0.9,'riya@gmail.com');
58 |
59 | INSERT INTO EMPLOYEE
60 | VALUES(106,'NEHA','FEMALE',6,'BARDOLI','PROFESSOR',30000,0.3,'neha66@gmail.com');
61 |
62 | INSERT INTO EMPLOYEE
63 | VALUES(107,'SMIT','MALE',1,'DELHI','SALEMAN',15000,10,'smit77@gmail.com');
64 |
65 | INSERT INTO EMPLOYEE
66 | VALUES(108,'AYUSH','MALE',1,'PUNE','MANEGER',30000,4,'ayush88@gmail.com');
67 |
68 | INSERT INTO EMPLOYEE
69 | VALUES(109,'AJAY','MALE',7,'SURAT','HOD',38000,3,'ajay999@gmail.com');
70 |
71 | INSERT INTO EMPLOYEE
72 | VALUES(110,'RAJ','MALE',5,'NAVSARI','DIN',30000,1,'raj110@gmail.com');
73 |
74 | QUERIES:
75 |
76 | 1. Display all Department belonging to location ‘Surat’.
77 |
78 | SELECT * FROM DEPARTMENT
79 | WHERE UPPER(LOCATION='SURAT');
80 |
81 | 2. List all department name statring with ‘A’.
82 |
83 | SELECT * FROM DEPARTMENT
84 | WHERE UPPER(DEPT_NAME LIKE 'A%');
85 |
86 | 3. List all departments whose number is between 1 and 100.
87 |
88 | SELECT * FROM DEPARTMENT
89 | WHERE DEPT_NO BETWEEN 1 AND 100;
90 |
91 | 4. Delete ‘TRG’ department.
92 |
93 | DELETE FROM DEPARTMENT
94 | WHERE UPPER(DEPT_NAME LIKE 'TRG');
95 |
96 | 5. Change department name ‘BBA’ to ‘IT’.
97 |
98 | UPDATE DEPARTMENT
99 | SET DEPT_NAME='IT'
100 | WHERE UPPER(DEPT_NAME='BBA');
101 |
102 | 6. Update the location whose dept_name second letter is ‘a’.
103 |
104 | UPDATE DEPARTMENT
105 | SET LOCATION='TAPI'
106 | WHERE UPPER(DEPT_NAME LIKE '_A%');
107 |
108 | 7. Display data whose location is ‘Baroda’, ‘Surat’ and ‘Ahemdabad’.
109 |
110 | SELECT * FROM DEPARTMENT
111 | WHERE UPPER(LOCATION IN ('BARODA','SURAT','AHEMDABAD'));
112 |
113 | 8. Display data who are not from ‘sales’ and ‘marketing’ department.
114 |
115 | SELECT * FROM DEPARTMENT
116 | WHERE UPPER(DEPT_NAME NOT IN('SALES','MARKETING'));
117 |
118 | 9. List all records of each table in ascending order.
119 |
120 | SELECT * FROM DEPARTMENT
121 | ORDER BY DEPT_NAME;
122 |
123 | 10. Display female employee list.
124 |
125 | SELECT * FROM EMPLOYEE
126 | WHERE LOWER(GENDER LIKE 'female');
127 |
128 | 11. Display all record order by emp_name.
129 |
130 | SELECT * FROM EMPLOYEE
131 | ORDER BY EMP_NAME;
132 |
133 | 12. Find the names of the employee who has salary less than 5000 and greater than
134 | 2000.
135 |
136 | SELECT EMP_NAME FROM EMPLOYEE
137 | WHERE SALARY<5000 AND SALARY>2000;
138 |
139 | OR
140 |
141 | SELECT EMP_NAME FROM EMPLOYEE
142 | WHERE SALARY BETWEEN 2000 AND 5000;
143 |
144 | 13. Display the names and the designation of all female employee in descending
145 | order.
146 |
147 | SELECT EMP_NAME,DESIGNATION FROM EMPLOYEE
148 | WHERE LOWER(GENDER='female')
149 | ORDER BY EMP_NAME DESC;
150 |
151 | 14. Display the names of all the employees who names starts with ‘A’ ends with ‘A’.
152 |
153 | SELECT EMP_NAME FROM EMPLOYEE
154 | WHERE UPPER(EMP_NAME LIKE 'A%A');
155 |
156 | 15. Find the name of employee and salary for those who had obtain minimum
157 | salary.
158 |
159 | SELECT EMP_NAME, MIN(SALARY) "MINIMUM SALARY OF EMPLOYEE" FROM EMPLOYEE;
160 |
161 | 16. Add 10% raise in salary of all employees whose department is ‘IT’.
162 |
163 | UPDATE EMPLOYEE
164 | SET SALARY=SALARY+(SALARY*10/100)
165 | WHERE DEPT_NO=(SELECT DEPT_NO FROM DEPARTMENT WHERE DEPT_NAME='IT');
166 |
167 | 17. List names of employees who are fresher’s (less than 1 year of experience).
168 |
169 | SELECT EMP_NAME FROM EMPLOYEE
170 | WHERE EXPERIENCE<1;
171 |
172 | 18. List department wise names of employees who has more than 5 years of
173 | experience.
174 |
175 | SELECT * FROM EMPLOYEE
176 | WHERE EXPERIENCE>5
177 | ORDER BY DEPT_NO;
178 |
179 | OR
180 |
181 | SELECT E.EMP_NAME,D.DEPT_NAME FROM EMPLOYEE E,DEPARTMENT D
182 | WHERE EXPERIENCE>5 AND E.DEPT_NO=D.DEPT_NO
183 | ORDER BY DEPT_NAME;
184 |
185 | 19. List department having no employees.
186 |
187 | SELECT * FROM DEPARTMENT
188 | WHERE DEPT_NO NOT IN(SELECT DEPT_NO FROM EMPLOYEE);
189 |
190 | 20. Delete the employee whose salary is less than 10000.
191 |
192 | DELETE FROM EMPLOYEE
193 | WHERE SALARY<10000;
194 |
--------------------------------------------------------------------------------
/Solution/Solution Lab-4.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "id": "d8b4c6a4",
6 | "metadata": {},
7 | "source": [
8 | "# Importing pandas library"
9 | ]
10 | },
11 | {
12 | "cell_type": "code",
13 | "execution_count": 13,
14 | "id": "0e997fc2",
15 | "metadata": {},
16 | "outputs": [],
17 | "source": [
18 | "import pandas as pd"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "id": "b50ecc56",
24 | "metadata": {},
25 | "source": [
26 | "# 1. Create a list consists of ten names. Use the list to store the list elements in DataFrame. Display the created dataframe."
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 21,
32 | "id": "61d66507",
33 | "metadata": {},
34 | "outputs": [
35 | {
36 | "name": "stdout",
37 | "output_type": "stream",
38 | "text": [
39 | " 0\n",
40 | "0 OM\n",
41 | "1 SAI\n",
42 | "2 RAM\n",
43 | "3 SHYAM\n",
44 | "4 GANESH\n",
45 | "5 GEETA\n",
46 | "6 RITA\n",
47 | "7 SITA\n",
48 | "8 RADHA\n",
49 | "9 SHIDHI\n"
50 | ]
51 | }
52 | ],
53 | "source": [
54 | "l=['OM','SAI','RAM','SHYAM','GANESH','GEETA','RITA','SITA','RADHA','SHIDHI']\n",
55 | "df=pd.DataFrame(l)\n",
56 | "print(df)"
57 | ]
58 | },
59 | {
60 | "cell_type": "markdown",
61 | "id": "7da4ed3a",
62 | "metadata": {},
63 | "source": [
64 | "# 2. Create DataFrame from Dictionary which is consists of lists. Create following dictionary consists of three keys and each of them contain corresponding list of values. \n",
65 | " d = {'Student’: ['Rutvik', 'Pankti', 'Evaan', 'Dhyan'], \n",
66 | " 'City': ['Pune', 'Delhi', 'Surat', 'Houston'], \n",
67 | " 'Age': [22, 16, 5, 13]} \n"
68 | ]
69 | },
70 | {
71 | "cell_type": "code",
72 | "execution_count": 22,
73 | "id": "6b088f86",
74 | "metadata": {},
75 | "outputs": [
76 | {
77 | "name": "stdout",
78 | "output_type": "stream",
79 | "text": [
80 | "DataFrame is successfully created.\n"
81 | ]
82 | }
83 | ],
84 | "source": [
85 | "d = {'Student': ['Rutvik', 'Pankti', 'Evaan', 'Dhyan'], \n",
86 | " 'City': ['Pune', 'Delhi', 'Surat', 'Houston'], \n",
87 | " 'Age': [22, 16, 5, 13]} \n",
88 | "print('DataFrame is successfully created.')"
89 | ]
90 | },
91 | {
92 | "cell_type": "markdown",
93 | "id": "217f98ac",
94 | "metadata": {},
95 | "source": [
96 | "# 3. Store above dictionary in dataframe and display the created dataframe."
97 | ]
98 | },
99 | {
100 | "cell_type": "code",
101 | "execution_count": 23,
102 | "id": "859c6938",
103 | "metadata": {},
104 | "outputs": [
105 | {
106 | "data": {
107 | "text/html": [
108 | "
\n",
109 | "\n",
122 | "
\n",
123 | " \n",
124 | " \n",
125 | " | \n",
126 | " Student | \n",
127 | " City | \n",
128 | " Age | \n",
129 | "
\n",
130 | " \n",
131 | " \n",
132 | " \n",
133 | " | 0 | \n",
134 | " Rutvik | \n",
135 | " Pune | \n",
136 | " 22 | \n",
137 | "
\n",
138 | " \n",
139 | " | 1 | \n",
140 | " Pankti | \n",
141 | " Delhi | \n",
142 | " 16 | \n",
143 | "
\n",
144 | " \n",
145 | " | 2 | \n",
146 | " Evaan | \n",
147 | " Surat | \n",
148 | " 5 | \n",
149 | "
\n",
150 | " \n",
151 | " | 3 | \n",
152 | " Dhyan | \n",
153 | " Houston | \n",
154 | " 13 | \n",
155 | "
\n",
156 | " \n",
157 | "
\n",
158 | "
"
159 | ],
160 | "text/plain": [
161 | " Student City Age\n",
162 | "0 Rutvik Pune 22\n",
163 | "1 Pankti Delhi 16\n",
164 | "2 Evaan Surat 5\n",
165 | "3 Dhyan Houston 13"
166 | ]
167 | },
168 | "execution_count": 23,
169 | "metadata": {},
170 | "output_type": "execute_result"
171 | }
172 | ],
173 | "source": [
174 | "df=pd.DataFrame(d)\n",
175 | "df"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "f4b978f8",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": []
185 | }
186 | ],
187 | "metadata": {
188 | "kernelspec": {
189 | "display_name": "Python 3 (ipykernel)",
190 | "language": "python",
191 | "name": "python3"
192 | },
193 | "language_info": {
194 | "codemirror_mode": {
195 | "name": "ipython",
196 | "version": 3
197 | },
198 | "file_extension": ".py",
199 | "mimetype": "text/x-python",
200 | "name": "python",
201 | "nbconvert_exporter": "python",
202 | "pygments_lexer": "ipython3",
203 | "version": "3.10.6"
204 | }
205 | },
206 | "nbformat": 4,
207 | "nbformat_minor": 5
208 | }
209 |
--------------------------------------------------------------------------------
/Solution/Solution Lab-2.txt:
--------------------------------------------------------------------------------
1 | CREATE TABLE STUDENT
2 | (
3 | ROLLNO INT PRIMARY KEY,
4 | NAME VARCHAR2(20) NOT NULL,
5 | CLASS CHAR(2) CHECK(CLASS='FY' OR CLASS='SY' OR CLASS='TY'),
6 | BIRTHDATE DATE
7 | );
8 |
9 | INSERT INTO STUDENT
10 | VALUES(1,'RAJ','TY','12/06/2002');
11 |
12 | INSERT INTO STUDENT
13 | VALUES(2,'SUMIT','TY','18/09/2002');
14 |
15 | INSERT INTO STUDENT
16 | VALUES(3,'SHAHIL','TY','05/12/2002');
17 |
18 | INSERT INTO STUDENT
19 | VALUES(4,'RAVI','SY','11/07/2003');
20 |
21 | INSERT INTO STUDENT
22 | VALUES(5,'VISHAL','SY','25/04/2003');
23 |
24 | INSERT INTO STUDENT
25 | VALUES(6,'AJAY','SY','22/01/2003');
26 |
27 | INSERT INTO STUDENT
28 | VALUES(7,'NIL','SY','29/03/2002');
29 |
30 | INSERT INTO STUDENT
31 | VALUES(8,'KEYUR','FY','19/12/2004');
32 |
33 | INSERT INTO STUDENT
34 | VALUES(9,'JAY','FY','22/10/2004');
35 |
36 | INSERT INTO STUDENT
37 | VALUES(10,'MEET','FY','02/09/2004');
38 |
39 |
40 | CREATE TABLE COURSE
41 | (
42 | COURSENO INT PRIMARY KEY,
43 | COURSENAME VARCHAR2(30) NOT NULL,
44 | MAX_MARKS INT DEFAULT(100),
45 | PASS_MARKS INT DEFAULT(35)
46 | );
47 |
48 | INSERT INTO COURSE(COURSENO,COURSENAME)
49 | VALUES(101,'DATABASE MANAGEMENT SYSTEM');
50 |
51 | INSERT INTO COURSE(COURSENO,COURSENAME)
52 | VALUES(102,'COMPUTER NETWORK');
53 |
54 | INSERT INTO COURSE(COURSENO,COURSENAME)
55 | VALUES(103,'DATA SCIENCE');
56 |
57 | INSERT INTO COURSE(COURSENO,COURSENAME)
58 | VALUES(104,'MACHINE LEARNING');
59 |
60 | INSERT INTO COURSE(COURSENO,COURSENAME)
61 | VALUES(105,'DIGITAL MARKETER');
62 |
63 | INSERT INTO COURSE(COURSENO,COURSENAME)
64 | VALUES(106,'AI ENGINEER');
65 |
66 | INSERT INTO COURSE(COURSENO,COURSENAME)
67 | VALUES(107,'SOFTWARE DEVELOPER');
68 |
69 | INSERT INTO COURSE(COURSENO,COURSENAME)
70 | VALUES(108,'BIG DATA');
71 |
72 | INSERT INTO COURSE(COURSENO,COURSENAME)
73 | VALUES(109,'CYBER SECURITY');
74 |
75 | INSERT INTO COURSE(COURSENO,COURSENAME)
76 | VALUES(110,'MANAGEMENT');
77 |
78 | CREATE TABLE SC
79 | (
80 | ROLLNO INT,
81 | COURSENO INT,
82 | MARKS INT,
83 | PRIMARY KEY(ROLLNO,COURSENO),
84 | FOREIGN KEY(ROLLNO) REFERENCES STUDENT(ROLLNO),
85 | FOREIGN KEY(COURSENO) REFERENCES COURSE(COURSENO)
86 | );
87 |
88 | INSERT INTO SC
89 | VALUES(1,101,90);
90 |
91 | INSERT INTO SC
92 | VALUES(2,101,93);
93 |
94 | INSERT INTO SC
95 | VALUES(3,101,60);
96 |
97 | INSERT INTO SC
98 | VALUES(4,101,30);
99 |
100 | INSERT INTO SC
101 | VALUES(10,102,60);
102 |
103 | INSERT INTO SC
104 | VALUES(10,103,80);
105 |
106 | INSERT INTO SC
107 | VALUES(5,102,90);
108 |
109 | INSERT INTO SC
110 | VALUES(7,102,90);
111 |
112 | INSERT INTO SC
113 | VALUES(2,103,90);
114 |
115 | INSERT INTO SC
116 | VALUES(8,104,90);
117 |
118 | INSERT INTO SC
119 | VALUES(5,105,90);
120 |
121 | INSERT INTO SC
122 | VALUES(9,105,90);
123 |
124 | INSERT INTO SC
125 | VALUES(10,106,90);
126 |
127 | INSERT INTO SC
128 | VALUES(2,107,90);
129 |
130 | INSERT INTO SC
131 | VALUES(3,106,90);
132 |
133 | INSERT INTO SC
134 | VALUES(7,107,90);
135 |
136 | INSERT INTO SC
137 | VALUES(4,109,90);
138 |
139 | INSERT INTO SC
140 | VALUES(9,102,30);
141 |
142 | INSERT INTO SC
143 | VALUES(5,101,30);
144 |
145 | INSERT INTO SC
146 | VALUES(5,109,80);
147 |
148 | QUERISE:
149 |
150 | 1. Display details of student who takes ‘Database Management System’ course.
151 |
152 | SELECT S.* FROM STUDENT S,SC M
153 | WHERE S.ROLLNO=M.ROLLNO AND M.COURSENO=(SELECT COURSENO FROM COURSE WHERE UPPER(COURSENAME='DATABASE MANAGEMENT SYSTEM'));
154 |
155 | 2. Display the names of students who have scored more than 70% in Computer
156 | Networks and have not failed in any subject.
157 |
158 | SELECT S.NAME,M.MARKS=(M.MARKS*100/100) FROM STUDENT S,COURSE C, SC M
159 | WHERE M.MARKS>70 AND C.COURSENAME="COMPUTER NETWORK" AND M.ROLLNO IN(SELECT ROLLNO FROM SC WHERE ROLLNO NOT IN (SELECT ROLLNO FROM SC,COURSE WHERE MARKS30;
172 |
173 | 5. Display all course name.
174 |
175 | SELECT COURSENAME FROM COURSE;
176 |
177 | 6. Display the student details who have secure 1st rank in ‘Computer Network’
178 | course.
179 |
180 | SELECT *,MAX(MARKS) FROM SC M,STUDENT S
181 | WHERE S.ROLLNO=M.ROLLNO AND M.COURSENO=(SELECT COURSENO FROM COURSE WHERE UPPER(COURSENAME='COMPUTER NETWORK'));
182 |
183 | 7. Display all SY student list along with course name.
184 |
185 | SELECT S.*,C.COURSENAME FROM STUDENT S,SC M,COURSE C
186 | WHERE S.ROLLNO=M.ROLLNO AND C.COURSENO=M.COURSENO AND S.CLASS='SY';
187 |
188 | 8. Display the average marks obtained by each student.
189 |
190 | SELECT *,AVG(MARKS) FROM SC
191 | GROUP BY ROLLNO;
192 |
193 | 9. Write a trigger which does not allow deletion of student whose pass_mark is
194 | greater than 35.
195 |
196 | CREATE TRIGGER DEL_TRG
197 | BEFORE DELETE ON STUDENT
198 | BEGIN
199 | SELECT CASE
200 | WHEN (SELECT S.*,C.*,M.* FROM STUDENT S, COURSE C,SC M WHERE S.ROLLNO=M.ROLLNO AND
201 | C.COURSENO=M.COURSENO AND C.PASS_MARKS>35)
202 | THEN RAISE(ABORT,'WHEN THE SUBJECT HAVE PASSING MARKS MORE THEN 35 ')
203 | END;
204 | END;
205 |
206 |
207 | 10. Write a trigger which does not allow insertion / updating student whose maxmarks more than 100 and less than 0
208 |
209 | (A) TRIGGER FOR INSERT RECORD.
210 |
211 | CREATE TRIGGER INSR_TRG
212 | BEFORE INSERT ON SC
213 | BEGIN
214 | SELECT
215 | CASE
216 | WHEN NEW.MARKS>100 OR NEW.MARKS<0
217 | THEN RAISE (ABORT,'PLEASE ENTER MARKS BETWEEEN 0 TO 100')
218 | END;
219 | END;
220 |
221 | (B) TRIGGER FOR UPDATE RECORD.
222 |
223 | CREATE TRIGGER UPD_TRG
224 | BEFORE UPDATE ON SC
225 | BEGIN
226 | SELECT
227 | CASE
228 |
229 | WHEN NEW.MARKS>100 OR NEW.MARKS<0
230 | THEN RAISE (ABORT,'PLEASE ENTER MARKS BETWEEEN 0 TO 100')
231 | END;
232 | END:
--------------------------------------------------------------------------------
/Solution/Solution Lab-3.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "id": "7e326d7d",
6 | "metadata": {},
7 | "source": [
8 | "# Importing pandas library"
9 | ]
10 | },
11 | {
12 | "cell_type": "code",
13 | "execution_count": 9,
14 | "id": "5fdd6f29",
15 | "metadata": {},
16 | "outputs": [],
17 | "source": [
18 | "import csv\n",
19 | "import pandas as pd"
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "id": "03e748e1",
25 | "metadata": {},
26 | "source": [
27 | "# 1.\tWrite 5 records using writer object in file."
28 | ]
29 | },
30 | {
31 | "cell_type": "code",
32 | "execution_count": 10,
33 | "id": "846cb8bc",
34 | "metadata": {},
35 | "outputs": [],
36 | "source": [
37 | "def Q1():\n",
38 | " with open('salary.csv','w',newline='') as sal:\n",
39 | " data=[['Empid','Empname','Department','Experience','Salary'],\n",
40 | " [1,'ABC','BCA','4 Years',40000],\n",
41 | " [2,'DEF','BBA','3 Years',30000],\n",
42 | " [3,'GHI','MCA','2 Years',20000],\n",
43 | " [4,'JKL','MBA','3 Years',30000],\n",
44 | " [5,'MNO','MCA','5 Years',50000]]\n",
45 | " w=csv.writer(sal)\n",
46 | " w.writerows(data)\n",
47 | " print('Data are Successfully Written.')"
48 | ]
49 | },
50 | {
51 | "cell_type": "markdown",
52 | "id": "3cba11d9",
53 | "metadata": {},
54 | "source": [
55 | "# 2.\tRead file using reader object and print file in proper format."
56 | ]
57 | },
58 | {
59 | "cell_type": "code",
60 | "execution_count": 11,
61 | "id": "93dc19b2",
62 | "metadata": {},
63 | "outputs": [],
64 | "source": [
65 | "def Q2():\n",
66 | " with open('salary.csv','r',newline='') as sal:\n",
67 | " r=csv.reader(sal)\n",
68 | " for i in sal:\n",
69 | " print(i)"
70 | ]
71 | },
72 | {
73 | "cell_type": "markdown",
74 | "id": "ea736d42",
75 | "metadata": {},
76 | "source": [
77 | "# 3.\tAppend 2 record into file and display it."
78 | ]
79 | },
80 | {
81 | "cell_type": "code",
82 | "execution_count": 13,
83 | "id": "38785b59",
84 | "metadata": {},
85 | "outputs": [],
86 | "source": [
87 | "def Q3():\n",
88 | " with open('salary.csv','a',newline='') as sal:\n",
89 | " data=[[6,'PQR','BCA','6 Years',60000],\n",
90 | " [7,'XYZ','MBA','4 Years',40000]]\n",
91 | " w=csv.writer(sal)\n",
92 | " w.writerows(data)\n",
93 | " Q2()"
94 | ]
95 | },
96 | {
97 | "cell_type": "markdown",
98 | "id": "9f2fed11",
99 | "metadata": {},
100 | "source": [
101 | "# 4.\tRead data from file and print total salary of “BCA” department."
102 | ]
103 | },
104 | {
105 | "cell_type": "code",
106 | "execution_count": 15,
107 | "id": "1dec758e",
108 | "metadata": {},
109 | "outputs": [],
110 | "source": [
111 | "def Q4():\n",
112 | " with open('salary.csv','r',newline='') as sal:\n",
113 | " data=csv.DictReader(sal)\n",
114 | " l=[]\n",
115 | " s=0\n",
116 | " for i in data:\n",
117 | " d=i['Department']\n",
118 | " if d=='BCA':\n",
119 | " s+=int(i['Salary'])\n",
120 | " print('The total Salary of BCA Department is : {}'.format(s))"
121 | ]
122 | },
123 | {
124 | "cell_type": "markdown",
125 | "id": "6aaa6095",
126 | "metadata": {},
127 | "source": [
128 | "# 5.\tRead file using PANDA library and display records."
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": 16,
134 | "id": "8ffc6744",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "def Q5():\n",
139 | " df=pd.read_csv('salary.csv')\n",
140 | " print(df)"
141 | ]
142 | },
143 | {
144 | "cell_type": "code",
145 | "execution_count": 17,
146 | "id": "6c7fa833",
147 | "metadata": {},
148 | "outputs": [
149 | {
150 | "name": "stdout",
151 | "output_type": "stream",
152 | "text": [
153 | "Data are Successfully Written.\n"
154 | ]
155 | }
156 | ],
157 | "source": [
158 | "Q1()"
159 | ]
160 | },
161 | {
162 | "cell_type": "code",
163 | "execution_count": 18,
164 | "id": "3ab565fc",
165 | "metadata": {},
166 | "outputs": [
167 | {
168 | "name": "stdout",
169 | "output_type": "stream",
170 | "text": [
171 | "Empid,Empname,Department,Experience,Salary\r\n",
172 | "\n",
173 | "1,ABC,BCA,4 Years,40000\r\n",
174 | "\n",
175 | "2,DEF,BBA,3 Years,30000\r\n",
176 | "\n",
177 | "3,GHI,MCA,2 Years,20000\r\n",
178 | "\n",
179 | "4,JKL,MBA,3 Years,30000\r\n",
180 | "\n",
181 | "5,MNO,MCA,5 Years,50000\r\n",
182 | "\n"
183 | ]
184 | }
185 | ],
186 | "source": [
187 | "Q2()"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": 19,
193 | "id": "6c3044e7",
194 | "metadata": {},
195 | "outputs": [
196 | {
197 | "name": "stdout",
198 | "output_type": "stream",
199 | "text": [
200 | "Empid,Empname,Department,Experience,Salary\r\n",
201 | "\n",
202 | "1,ABC,BCA,4 Years,40000\r\n",
203 | "\n",
204 | "2,DEF,BBA,3 Years,30000\r\n",
205 | "\n",
206 | "3,GHI,MCA,2 Years,20000\r\n",
207 | "\n",
208 | "4,JKL,MBA,3 Years,30000\r\n",
209 | "\n",
210 | "5,MNO,MCA,5 Years,50000\r\n",
211 | "\n",
212 | "6,PQR,BCA,6 Years,60000\r\n",
213 | "\n",
214 | "7,XYZ,MBA,4 Years,40000\r\n",
215 | "\n"
216 | ]
217 | }
218 | ],
219 | "source": [
220 | "Q3()"
221 | ]
222 | },
223 | {
224 | "cell_type": "code",
225 | "execution_count": 20,
226 | "id": "a3f2ab9f",
227 | "metadata": {},
228 | "outputs": [
229 | {
230 | "name": "stdout",
231 | "output_type": "stream",
232 | "text": [
233 | "The total Salary of BCA Department is : 100000\n"
234 | ]
235 | }
236 | ],
237 | "source": [
238 | "Q4()"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": 21,
244 | "id": "910a1fdc",
245 | "metadata": {},
246 | "outputs": [
247 | {
248 | "name": "stdout",
249 | "output_type": "stream",
250 | "text": [
251 | " Empid Empname Department Experience Salary\n",
252 | "0 1 ABC BCA 4 Years 40000\n",
253 | "1 2 DEF BBA 3 Years 30000\n",
254 | "2 3 GHI MCA 2 Years 20000\n",
255 | "3 4 JKL MBA 3 Years 30000\n",
256 | "4 5 MNO MCA 5 Years 50000\n",
257 | "5 6 PQR BCA 6 Years 60000\n",
258 | "6 7 XYZ MBA 4 Years 40000\n"
259 | ]
260 | }
261 | ],
262 | "source": [
263 | "Q5()"
264 | ]
265 | },
266 | {
267 | "cell_type": "code",
268 | "execution_count": null,
269 | "id": "47adc934",
270 | "metadata": {},
271 | "outputs": [],
272 | "source": []
273 | }
274 | ],
275 | "metadata": {
276 | "kernelspec": {
277 | "display_name": "Python 3 (ipykernel)",
278 | "language": "python",
279 | "name": "python3"
280 | },
281 | "language_info": {
282 | "codemirror_mode": {
283 | "name": "ipython",
284 | "version": 3
285 | },
286 | "file_extension": ".py",
287 | "mimetype": "text/x-python",
288 | "name": "python",
289 | "nbconvert_exporter": "python",
290 | "pygments_lexer": "ipython3",
291 | "version": "3.10.6"
292 | }
293 | },
294 | "nbformat": 4,
295 | "nbformat_minor": 5
296 | }
297 |
--------------------------------------------------------------------------------
/Solution/Solution Lab-5.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "id": "34ae2794",
6 | "metadata": {},
7 | "source": [
8 | "# Importing pandas library"
9 | ]
10 | },
11 | {
12 | "cell_type": "code",
13 | "execution_count": 63,
14 | "id": "9458a9b3",
15 | "metadata": {},
16 | "outputs": [],
17 | "source": [
18 | "import pandas as pd"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "id": "84ef0cfe",
24 | "metadata": {},
25 | "source": [
26 | "# 1.\tExport data into csv file and read into Dataframe."
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 64,
32 | "id": "b82aac65",
33 | "metadata": {},
34 | "outputs": [],
35 | "source": [
36 | "df=pd.read_csv('C:\\sqlite\\student_travel.csv')"
37 | ]
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "id": "f700053b",
42 | "metadata": {},
43 | "source": [
44 | "# 2.\tDisplay information of dataframe. Name the column who has missing value."
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 65,
50 | "id": "b5e8755e",
51 | "metadata": {},
52 | "outputs": [
53 | {
54 | "name": "stdout",
55 | "output_type": "stream",
56 | "text": [
57 | "\n",
58 | "RangeIndex: 20 entries, 0 to 19\n",
59 | "Data columns (total 6 columns):\n",
60 | " # Column Non-Null Count Dtype \n",
61 | "--- ------ -------------- ----- \n",
62 | " 0 SID 20 non-null int64 \n",
63 | " 1 COURSE 18 non-null object\n",
64 | " 2 SNAME 20 non-null object\n",
65 | " 3 CITY 19 non-null object\n",
66 | " 4 TRAVEL_BY 20 non-null object\n",
67 | " 5 TRAVEL_EXPENSE 20 non-null int64 \n",
68 | "dtypes: int64(2), object(4)\n",
69 | "memory usage: 1.1+ KB\n"
70 | ]
71 | }
72 | ],
73 | "source": [
74 | "df.info()"
75 | ]
76 | },
77 | {
78 | "cell_type": "markdown",
79 | "id": "0e6b344f",
80 | "metadata": {},
81 | "source": [
82 | "# 3.\tReplace missing value by mean of that column."
83 | ]
84 | },
85 | {
86 | "cell_type": "code",
87 | "execution_count": 66,
88 | "id": "4d96c2f9",
89 | "metadata": {},
90 | "outputs": [
91 | {
92 | "name": "stderr",
93 | "output_type": "stream",
94 | "text": [
95 | "C:\\Users\\HP\\AppData\\Local\\Temp\\ipykernel_12896\\634187881.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.\n",
96 | " df.fillna(df.mean())\n"
97 | ]
98 | },
99 | {
100 | "data": {
101 | "text/html": [
102 | "\n",
103 | "\n",
116 | "
\n",
117 | " \n",
118 | " \n",
119 | " | \n",
120 | " SID | \n",
121 | " COURSE | \n",
122 | " SNAME | \n",
123 | " CITY | \n",
124 | " TRAVEL_BY | \n",
125 | " TRAVEL_EXPENSE | \n",
126 | "
\n",
127 | " \n",
128 | " \n",
129 | " \n",
130 | " | 0 | \n",
131 | " 1 | \n",
132 | " BCA | \n",
133 | " LAXMAN | \n",
134 | " SURAT | \n",
135 | " BIKE | \n",
136 | " 50 | \n",
137 | "
\n",
138 | " \n",
139 | " | 1 | \n",
140 | " 2 | \n",
141 | " BCA | \n",
142 | " XMAN | \n",
143 | " BARDOLI | \n",
144 | " BUS | \n",
145 | " 25 | \n",
146 | "
\n",
147 | " \n",
148 | " | 2 | \n",
149 | " 3 | \n",
150 | " BCA | \n",
151 | " AXMAN | \n",
152 | " VESU | \n",
153 | " CAR | \n",
154 | " 100 | \n",
155 | "
\n",
156 | " \n",
157 | " | 3 | \n",
158 | " 4 | \n",
159 | " BCA | \n",
160 | " LAMAN | \n",
161 | " SURAT | \n",
162 | " CAR | \n",
163 | " 100 | \n",
164 | "
\n",
165 | " \n",
166 | " | 4 | \n",
167 | " 5 | \n",
168 | " BCA | \n",
169 | " AMAN | \n",
170 | " BARDOLI | \n",
171 | " BUS | \n",
172 | " 25 | \n",
173 | "
\n",
174 | " \n",
175 | " | 5 | \n",
176 | " 6 | \n",
177 | " BCA | \n",
178 | " CHMAN | \n",
179 | " VESU | \n",
180 | " CAR | \n",
181 | " 100 | \n",
182 | "
\n",
183 | " \n",
184 | " | 6 | \n",
185 | " 7 | \n",
186 | " BCA | \n",
187 | " MAN | \n",
188 | " BARDOLI | \n",
189 | " BUS | \n",
190 | " 20 | \n",
191 | "
\n",
192 | " \n",
193 | " | 7 | \n",
194 | " 8 | \n",
195 | " BCA | \n",
196 | " ABC | \n",
197 | " VESU | \n",
198 | " CAR | \n",
199 | " 100 | \n",
200 | "
\n",
201 | " \n",
202 | " | 8 | \n",
203 | " 9 | \n",
204 | " BCA | \n",
205 | " XYZ | \n",
206 | " SURAT | \n",
207 | " BUS | \n",
208 | " 20 | \n",
209 | "
\n",
210 | " \n",
211 | " | 9 | \n",
212 | " 10 | \n",
213 | " BCA | \n",
214 | " MNO | \n",
215 | " BARDOLI | \n",
216 | " BIKE | \n",
217 | " 50 | \n",
218 | "
\n",
219 | " \n",
220 | " | 10 | \n",
221 | " 11 | \n",
222 | " BCA | \n",
223 | " CDN | \n",
224 | " VESU | \n",
225 | " BIKE | \n",
226 | " 50 | \n",
227 | "
\n",
228 | " \n",
229 | " | 11 | \n",
230 | " 12 | \n",
231 | " BBA | \n",
232 | " SRM | \n",
233 | " BARDOLI | \n",
234 | " BUS | \n",
235 | " 20 | \n",
236 | "
\n",
237 | " \n",
238 | " | 12 | \n",
239 | " 13 | \n",
240 | " NaN | \n",
241 | " OM | \n",
242 | " BARDOLI | \n",
243 | " BIKE | \n",
244 | " 50 | \n",
245 | "
\n",
246 | " \n",
247 | " | 13 | \n",
248 | " 14 | \n",
249 | " BBA | \n",
250 | " SAI | \n",
251 | " SURAT | \n",
252 | " BUS | \n",
253 | " 20 | \n",
254 | "
\n",
255 | " \n",
256 | " | 14 | \n",
257 | " 15 | \n",
258 | " BCA | \n",
259 | " RAMA | \n",
260 | " VESU | \n",
261 | " CAR | \n",
262 | " 100 | \n",
263 | "
\n",
264 | " \n",
265 | " | 15 | \n",
266 | " 16 | \n",
267 | " BCA | \n",
268 | " AYUSH | \n",
269 | " BARDOLI | \n",
270 | " BUS | \n",
271 | " 40 | \n",
272 | "
\n",
273 | " \n",
274 | " | 16 | \n",
275 | " 17 | \n",
276 | " BCA | \n",
277 | " MEET | \n",
278 | " NaN | \n",
279 | " BIKE | \n",
280 | " 10 | \n",
281 | "
\n",
282 | " \n",
283 | " | 17 | \n",
284 | " 18 | \n",
285 | " NaN | \n",
286 | " DEV | \n",
287 | " SURAT | \n",
288 | " BUS | \n",
289 | " 500 | \n",
290 | "
\n",
291 | " \n",
292 | " | 18 | \n",
293 | " 19 | \n",
294 | " BBA | \n",
295 | " SMIT | \n",
296 | " BARDOLI | \n",
297 | " CAR | \n",
298 | " 70 | \n",
299 | "
\n",
300 | " \n",
301 | " | 19 | \n",
302 | " 20 | \n",
303 | " BCA | \n",
304 | " ANZAR | \n",
305 | " BARDOLI | \n",
306 | " BUS | \n",
307 | " 30 | \n",
308 | "
\n",
309 | " \n",
310 | "
\n",
311 | "
"
312 | ],
313 | "text/plain": [
314 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
315 | "0 1 BCA LAXMAN SURAT BIKE 50\n",
316 | "1 2 BCA XMAN BARDOLI BUS 25\n",
317 | "2 3 BCA AXMAN VESU CAR 100\n",
318 | "3 4 BCA LAMAN SURAT CAR 100\n",
319 | "4 5 BCA AMAN BARDOLI BUS 25\n",
320 | "5 6 BCA CHMAN VESU CAR 100\n",
321 | "6 7 BCA MAN BARDOLI BUS 20\n",
322 | "7 8 BCA ABC VESU CAR 100\n",
323 | "8 9 BCA XYZ SURAT BUS 20\n",
324 | "9 10 BCA MNO BARDOLI BIKE 50\n",
325 | "10 11 BCA CDN VESU BIKE 50\n",
326 | "11 12 BBA SRM BARDOLI BUS 20\n",
327 | "12 13 NaN OM BARDOLI BIKE 50\n",
328 | "13 14 BBA SAI SURAT BUS 20\n",
329 | "14 15 BCA RAMA VESU CAR 100\n",
330 | "15 16 BCA AYUSH BARDOLI BUS 40\n",
331 | "16 17 BCA MEET NaN BIKE 10\n",
332 | "17 18 NaN DEV SURAT BUS 500\n",
333 | "18 19 BBA SMIT BARDOLI CAR 70\n",
334 | "19 20 BCA ANZAR BARDOLI BUS 30"
335 | ]
336 | },
337 | "execution_count": 66,
338 | "metadata": {},
339 | "output_type": "execute_result"
340 | }
341 | ],
342 | "source": [
343 | "df.fillna(df.mean())"
344 | ]
345 | },
346 | {
347 | "cell_type": "markdown",
348 | "id": "adf32002",
349 | "metadata": {},
350 | "source": [
351 | "# 4. Print first two records only."
352 | ]
353 | },
354 | {
355 | "cell_type": "code",
356 | "execution_count": 67,
357 | "id": "edbd9d00",
358 | "metadata": {},
359 | "outputs": [
360 | {
361 | "data": {
362 | "text/html": [
363 | "\n",
364 | "\n",
377 | "
\n",
378 | " \n",
379 | " \n",
380 | " | \n",
381 | " SID | \n",
382 | " COURSE | \n",
383 | " SNAME | \n",
384 | " CITY | \n",
385 | " TRAVEL_BY | \n",
386 | " TRAVEL_EXPENSE | \n",
387 | "
\n",
388 | " \n",
389 | " \n",
390 | " \n",
391 | " | 0 | \n",
392 | " 1 | \n",
393 | " BCA | \n",
394 | " LAXMAN | \n",
395 | " SURAT | \n",
396 | " BIKE | \n",
397 | " 50 | \n",
398 | "
\n",
399 | " \n",
400 | " | 1 | \n",
401 | " 2 | \n",
402 | " BCA | \n",
403 | " XMAN | \n",
404 | " BARDOLI | \n",
405 | " BUS | \n",
406 | " 25 | \n",
407 | "
\n",
408 | " \n",
409 | "
\n",
410 | "
"
411 | ],
412 | "text/plain": [
413 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
414 | "0 1 BCA LAXMAN SURAT BIKE 50\n",
415 | "1 2 BCA XMAN BARDOLI BUS 25"
416 | ]
417 | },
418 | "execution_count": 67,
419 | "metadata": {},
420 | "output_type": "execute_result"
421 | }
422 | ],
423 | "source": [
424 | "df.head(2)"
425 | ]
426 | },
427 | {
428 | "cell_type": "markdown",
429 | "id": "254c074c",
430 | "metadata": {},
431 | "source": [
432 | "# 5. Print all record except last 5 records."
433 | ]
434 | },
435 | {
436 | "cell_type": "code",
437 | "execution_count": 68,
438 | "id": "c3f84411",
439 | "metadata": {},
440 | "outputs": [
441 | {
442 | "data": {
443 | "text/html": [
444 | "\n",
445 | "\n",
458 | "
\n",
459 | " \n",
460 | " \n",
461 | " | \n",
462 | " SID | \n",
463 | " COURSE | \n",
464 | " SNAME | \n",
465 | " CITY | \n",
466 | " TRAVEL_BY | \n",
467 | " TRAVEL_EXPENSE | \n",
468 | "
\n",
469 | " \n",
470 | " \n",
471 | " \n",
472 | " | 0 | \n",
473 | " 1 | \n",
474 | " BCA | \n",
475 | " LAXMAN | \n",
476 | " SURAT | \n",
477 | " BIKE | \n",
478 | " 50 | \n",
479 | "
\n",
480 | " \n",
481 | " | 1 | \n",
482 | " 2 | \n",
483 | " BCA | \n",
484 | " XMAN | \n",
485 | " BARDOLI | \n",
486 | " BUS | \n",
487 | " 25 | \n",
488 | "
\n",
489 | " \n",
490 | " | 2 | \n",
491 | " 3 | \n",
492 | " BCA | \n",
493 | " AXMAN | \n",
494 | " VESU | \n",
495 | " CAR | \n",
496 | " 100 | \n",
497 | "
\n",
498 | " \n",
499 | " | 3 | \n",
500 | " 4 | \n",
501 | " BCA | \n",
502 | " LAMAN | \n",
503 | " SURAT | \n",
504 | " CAR | \n",
505 | " 100 | \n",
506 | "
\n",
507 | " \n",
508 | " | 4 | \n",
509 | " 5 | \n",
510 | " BCA | \n",
511 | " AMAN | \n",
512 | " BARDOLI | \n",
513 | " BUS | \n",
514 | " 25 | \n",
515 | "
\n",
516 | " \n",
517 | " | 5 | \n",
518 | " 6 | \n",
519 | " BCA | \n",
520 | " CHMAN | \n",
521 | " VESU | \n",
522 | " CAR | \n",
523 | " 100 | \n",
524 | "
\n",
525 | " \n",
526 | " | 6 | \n",
527 | " 7 | \n",
528 | " BCA | \n",
529 | " MAN | \n",
530 | " BARDOLI | \n",
531 | " BUS | \n",
532 | " 20 | \n",
533 | "
\n",
534 | " \n",
535 | " | 7 | \n",
536 | " 8 | \n",
537 | " BCA | \n",
538 | " ABC | \n",
539 | " VESU | \n",
540 | " CAR | \n",
541 | " 100 | \n",
542 | "
\n",
543 | " \n",
544 | " | 8 | \n",
545 | " 9 | \n",
546 | " BCA | \n",
547 | " XYZ | \n",
548 | " SURAT | \n",
549 | " BUS | \n",
550 | " 20 | \n",
551 | "
\n",
552 | " \n",
553 | " | 9 | \n",
554 | " 10 | \n",
555 | " BCA | \n",
556 | " MNO | \n",
557 | " BARDOLI | \n",
558 | " BIKE | \n",
559 | " 50 | \n",
560 | "
\n",
561 | " \n",
562 | " | 10 | \n",
563 | " 11 | \n",
564 | " BCA | \n",
565 | " CDN | \n",
566 | " VESU | \n",
567 | " BIKE | \n",
568 | " 50 | \n",
569 | "
\n",
570 | " \n",
571 | " | 11 | \n",
572 | " 12 | \n",
573 | " BBA | \n",
574 | " SRM | \n",
575 | " BARDOLI | \n",
576 | " BUS | \n",
577 | " 20 | \n",
578 | "
\n",
579 | " \n",
580 | " | 12 | \n",
581 | " 13 | \n",
582 | " NaN | \n",
583 | " OM | \n",
584 | " BARDOLI | \n",
585 | " BIKE | \n",
586 | " 50 | \n",
587 | "
\n",
588 | " \n",
589 | " | 13 | \n",
590 | " 14 | \n",
591 | " BBA | \n",
592 | " SAI | \n",
593 | " SURAT | \n",
594 | " BUS | \n",
595 | " 20 | \n",
596 | "
\n",
597 | " \n",
598 | " | 14 | \n",
599 | " 15 | \n",
600 | " BCA | \n",
601 | " RAMA | \n",
602 | " VESU | \n",
603 | " CAR | \n",
604 | " 100 | \n",
605 | "
\n",
606 | " \n",
607 | "
\n",
608 | "
"
609 | ],
610 | "text/plain": [
611 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
612 | "0 1 BCA LAXMAN SURAT BIKE 50\n",
613 | "1 2 BCA XMAN BARDOLI BUS 25\n",
614 | "2 3 BCA AXMAN VESU CAR 100\n",
615 | "3 4 BCA LAMAN SURAT CAR 100\n",
616 | "4 5 BCA AMAN BARDOLI BUS 25\n",
617 | "5 6 BCA CHMAN VESU CAR 100\n",
618 | "6 7 BCA MAN BARDOLI BUS 20\n",
619 | "7 8 BCA ABC VESU CAR 100\n",
620 | "8 9 BCA XYZ SURAT BUS 20\n",
621 | "9 10 BCA MNO BARDOLI BIKE 50\n",
622 | "10 11 BCA CDN VESU BIKE 50\n",
623 | "11 12 BBA SRM BARDOLI BUS 20\n",
624 | "12 13 NaN OM BARDOLI BIKE 50\n",
625 | "13 14 BBA SAI SURAT BUS 20\n",
626 | "14 15 BCA RAMA VESU CAR 100"
627 | ]
628 | },
629 | "execution_count": 68,
630 | "metadata": {},
631 | "output_type": "execute_result"
632 | }
633 | ],
634 | "source": [
635 | "df.head(-5)"
636 | ]
637 | },
638 | {
639 | "cell_type": "markdown",
640 | "id": "c1d0f709",
641 | "metadata": {},
642 | "source": [
643 | "# 6. Print all record except first 10 records."
644 | ]
645 | },
646 | {
647 | "cell_type": "code",
648 | "execution_count": 69,
649 | "id": "1b7415c0",
650 | "metadata": {},
651 | "outputs": [
652 | {
653 | "data": {
654 | "text/html": [
655 | "\n",
656 | "\n",
669 | "
\n",
670 | " \n",
671 | " \n",
672 | " | \n",
673 | " SID | \n",
674 | " COURSE | \n",
675 | " SNAME | \n",
676 | " CITY | \n",
677 | " TRAVEL_BY | \n",
678 | " TRAVEL_EXPENSE | \n",
679 | "
\n",
680 | " \n",
681 | " \n",
682 | " \n",
683 | " | 10 | \n",
684 | " 11 | \n",
685 | " BCA | \n",
686 | " CDN | \n",
687 | " VESU | \n",
688 | " BIKE | \n",
689 | " 50 | \n",
690 | "
\n",
691 | " \n",
692 | " | 11 | \n",
693 | " 12 | \n",
694 | " BBA | \n",
695 | " SRM | \n",
696 | " BARDOLI | \n",
697 | " BUS | \n",
698 | " 20 | \n",
699 | "
\n",
700 | " \n",
701 | " | 12 | \n",
702 | " 13 | \n",
703 | " NaN | \n",
704 | " OM | \n",
705 | " BARDOLI | \n",
706 | " BIKE | \n",
707 | " 50 | \n",
708 | "
\n",
709 | " \n",
710 | " | 13 | \n",
711 | " 14 | \n",
712 | " BBA | \n",
713 | " SAI | \n",
714 | " SURAT | \n",
715 | " BUS | \n",
716 | " 20 | \n",
717 | "
\n",
718 | " \n",
719 | " | 14 | \n",
720 | " 15 | \n",
721 | " BCA | \n",
722 | " RAMA | \n",
723 | " VESU | \n",
724 | " CAR | \n",
725 | " 100 | \n",
726 | "
\n",
727 | " \n",
728 | " | 15 | \n",
729 | " 16 | \n",
730 | " BCA | \n",
731 | " AYUSH | \n",
732 | " BARDOLI | \n",
733 | " BUS | \n",
734 | " 40 | \n",
735 | "
\n",
736 | " \n",
737 | " | 16 | \n",
738 | " 17 | \n",
739 | " BCA | \n",
740 | " MEET | \n",
741 | " NaN | \n",
742 | " BIKE | \n",
743 | " 10 | \n",
744 | "
\n",
745 | " \n",
746 | " | 17 | \n",
747 | " 18 | \n",
748 | " NaN | \n",
749 | " DEV | \n",
750 | " SURAT | \n",
751 | " BUS | \n",
752 | " 500 | \n",
753 | "
\n",
754 | " \n",
755 | " | 18 | \n",
756 | " 19 | \n",
757 | " BBA | \n",
758 | " SMIT | \n",
759 | " BARDOLI | \n",
760 | " CAR | \n",
761 | " 70 | \n",
762 | "
\n",
763 | " \n",
764 | " | 19 | \n",
765 | " 20 | \n",
766 | " BCA | \n",
767 | " ANZAR | \n",
768 | " BARDOLI | \n",
769 | " BUS | \n",
770 | " 30 | \n",
771 | "
\n",
772 | " \n",
773 | "
\n",
774 | "
"
775 | ],
776 | "text/plain": [
777 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
778 | "10 11 BCA CDN VESU BIKE 50\n",
779 | "11 12 BBA SRM BARDOLI BUS 20\n",
780 | "12 13 NaN OM BARDOLI BIKE 50\n",
781 | "13 14 BBA SAI SURAT BUS 20\n",
782 | "14 15 BCA RAMA VESU CAR 100\n",
783 | "15 16 BCA AYUSH BARDOLI BUS 40\n",
784 | "16 17 BCA MEET NaN BIKE 10\n",
785 | "17 18 NaN DEV SURAT BUS 500\n",
786 | "18 19 BBA SMIT BARDOLI CAR 70\n",
787 | "19 20 BCA ANZAR BARDOLI BUS 30"
788 | ]
789 | },
790 | "execution_count": 69,
791 | "metadata": {},
792 | "output_type": "execute_result"
793 | }
794 | ],
795 | "source": [
796 | "df.tail(-10)"
797 | ]
798 | },
799 | {
800 | "cell_type": "markdown",
801 | "id": "215cf234",
802 | "metadata": {},
803 | "source": [
804 | "# 7. Group student based on city name."
805 | ]
806 | },
807 | {
808 | "cell_type": "code",
809 | "execution_count": 78,
810 | "id": "92c9e791",
811 | "metadata": {},
812 | "outputs": [
813 | {
814 | "data": {
815 | "text/html": [
816 | "\n",
817 | "\n",
830 | "
\n",
831 | " \n",
832 | " \n",
833 | " | \n",
834 | " | \n",
835 | " SID | \n",
836 | " TRAVEL_EXPENSE | \n",
837 | "
\n",
838 | " \n",
839 | " | CITY | \n",
840 | " SNAME | \n",
841 | " | \n",
842 | " | \n",
843 | "
\n",
844 | " \n",
845 | " \n",
846 | " \n",
847 | " | BARDOLI | \n",
848 | " AMAN | \n",
849 | " 5 | \n",
850 | " 25 | \n",
851 | "
\n",
852 | " \n",
853 | " | ANZAR | \n",
854 | " 20 | \n",
855 | " 30 | \n",
856 | "
\n",
857 | " \n",
858 | " | AYUSH | \n",
859 | " 16 | \n",
860 | " 40 | \n",
861 | "
\n",
862 | " \n",
863 | " | MAN | \n",
864 | " 7 | \n",
865 | " 20 | \n",
866 | "
\n",
867 | " \n",
868 | " | MNO | \n",
869 | " 10 | \n",
870 | " 50 | \n",
871 | "
\n",
872 | " \n",
873 | " | OM | \n",
874 | " 13 | \n",
875 | " 50 | \n",
876 | "
\n",
877 | " \n",
878 | " | SMIT | \n",
879 | " 19 | \n",
880 | " 70 | \n",
881 | "
\n",
882 | " \n",
883 | " | SRM | \n",
884 | " 12 | \n",
885 | " 20 | \n",
886 | "
\n",
887 | " \n",
888 | " | XMAN | \n",
889 | " 2 | \n",
890 | " 25 | \n",
891 | "
\n",
892 | " \n",
893 | " | SURAT | \n",
894 | " DEV | \n",
895 | " 18 | \n",
896 | " 500 | \n",
897 | "
\n",
898 | " \n",
899 | " | LAMAN | \n",
900 | " 4 | \n",
901 | " 100 | \n",
902 | "
\n",
903 | " \n",
904 | " | LAXMAN | \n",
905 | " 1 | \n",
906 | " 50 | \n",
907 | "
\n",
908 | " \n",
909 | " | SAI | \n",
910 | " 14 | \n",
911 | " 20 | \n",
912 | "
\n",
913 | " \n",
914 | " | XYZ | \n",
915 | " 9 | \n",
916 | " 20 | \n",
917 | "
\n",
918 | " \n",
919 | " | VESU | \n",
920 | " ABC | \n",
921 | " 8 | \n",
922 | " 100 | \n",
923 | "
\n",
924 | " \n",
925 | " | AXMAN | \n",
926 | " 3 | \n",
927 | " 100 | \n",
928 | "
\n",
929 | " \n",
930 | " | CDN | \n",
931 | " 11 | \n",
932 | " 50 | \n",
933 | "
\n",
934 | " \n",
935 | " | CHMAN | \n",
936 | " 6 | \n",
937 | " 100 | \n",
938 | "
\n",
939 | " \n",
940 | " | RAMA | \n",
941 | " 15 | \n",
942 | " 100 | \n",
943 | "
\n",
944 | " \n",
945 | "
\n",
946 | "
"
947 | ],
948 | "text/plain": [
949 | " SID TRAVEL_EXPENSE\n",
950 | "CITY SNAME \n",
951 | "BARDOLI AMAN 5 25\n",
952 | " ANZAR 20 30\n",
953 | " AYUSH 16 40\n",
954 | " MAN 7 20\n",
955 | " MNO 10 50\n",
956 | " OM 13 50\n",
957 | " SMIT 19 70\n",
958 | " SRM 12 20\n",
959 | " XMAN 2 25\n",
960 | "SURAT DEV 18 500\n",
961 | " LAMAN 4 100\n",
962 | " LAXMAN 1 50\n",
963 | " SAI 14 20\n",
964 | " XYZ 9 20\n",
965 | "VESU ABC 8 100\n",
966 | " AXMAN 3 100\n",
967 | " CDN 11 50\n",
968 | " CHMAN 6 100\n",
969 | " RAMA 15 100"
970 | ]
971 | },
972 | "execution_count": 78,
973 | "metadata": {},
974 | "output_type": "execute_result"
975 | }
976 | ],
977 | "source": [
978 | "df.groupby(['CITY','SNAME']).sum()"
979 | ]
980 | },
981 | {
982 | "cell_type": "markdown",
983 | "id": "794e7d9b",
984 | "metadata": {},
985 | "source": [
986 | "# 8. Sort records based on Travel by column."
987 | ]
988 | },
989 | {
990 | "cell_type": "code",
991 | "execution_count": 79,
992 | "id": "abb4abb1",
993 | "metadata": {},
994 | "outputs": [
995 | {
996 | "data": {
997 | "text/html": [
998 | "\n",
999 | "\n",
1012 | "
\n",
1013 | " \n",
1014 | " \n",
1015 | " | \n",
1016 | " SID | \n",
1017 | " COURSE | \n",
1018 | " SNAME | \n",
1019 | " CITY | \n",
1020 | " TRAVEL_BY | \n",
1021 | " TRAVEL_EXPENSE | \n",
1022 | "
\n",
1023 | " \n",
1024 | " \n",
1025 | " \n",
1026 | " | 0 | \n",
1027 | " 1 | \n",
1028 | " BCA | \n",
1029 | " LAXMAN | \n",
1030 | " SURAT | \n",
1031 | " BIKE | \n",
1032 | " 50 | \n",
1033 | "
\n",
1034 | " \n",
1035 | " | 16 | \n",
1036 | " 17 | \n",
1037 | " BCA | \n",
1038 | " MEET | \n",
1039 | " NaN | \n",
1040 | " BIKE | \n",
1041 | " 10 | \n",
1042 | "
\n",
1043 | " \n",
1044 | " | 12 | \n",
1045 | " 13 | \n",
1046 | " NaN | \n",
1047 | " OM | \n",
1048 | " BARDOLI | \n",
1049 | " BIKE | \n",
1050 | " 50 | \n",
1051 | "
\n",
1052 | " \n",
1053 | " | 10 | \n",
1054 | " 11 | \n",
1055 | " BCA | \n",
1056 | " CDN | \n",
1057 | " VESU | \n",
1058 | " BIKE | \n",
1059 | " 50 | \n",
1060 | "
\n",
1061 | " \n",
1062 | " | 9 | \n",
1063 | " 10 | \n",
1064 | " BCA | \n",
1065 | " MNO | \n",
1066 | " BARDOLI | \n",
1067 | " BIKE | \n",
1068 | " 50 | \n",
1069 | "
\n",
1070 | " \n",
1071 | " | 6 | \n",
1072 | " 7 | \n",
1073 | " BCA | \n",
1074 | " MAN | \n",
1075 | " BARDOLI | \n",
1076 | " BUS | \n",
1077 | " 20 | \n",
1078 | "
\n",
1079 | " \n",
1080 | " | 8 | \n",
1081 | " 9 | \n",
1082 | " BCA | \n",
1083 | " XYZ | \n",
1084 | " SURAT | \n",
1085 | " BUS | \n",
1086 | " 20 | \n",
1087 | "
\n",
1088 | " \n",
1089 | " | 11 | \n",
1090 | " 12 | \n",
1091 | " BBA | \n",
1092 | " SRM | \n",
1093 | " BARDOLI | \n",
1094 | " BUS | \n",
1095 | " 20 | \n",
1096 | "
\n",
1097 | " \n",
1098 | " | 13 | \n",
1099 | " 14 | \n",
1100 | " BBA | \n",
1101 | " SAI | \n",
1102 | " SURAT | \n",
1103 | " BUS | \n",
1104 | " 20 | \n",
1105 | "
\n",
1106 | " \n",
1107 | " | 15 | \n",
1108 | " 16 | \n",
1109 | " BCA | \n",
1110 | " AYUSH | \n",
1111 | " BARDOLI | \n",
1112 | " BUS | \n",
1113 | " 40 | \n",
1114 | "
\n",
1115 | " \n",
1116 | " | 1 | \n",
1117 | " 2 | \n",
1118 | " BCA | \n",
1119 | " XMAN | \n",
1120 | " BARDOLI | \n",
1121 | " BUS | \n",
1122 | " 25 | \n",
1123 | "
\n",
1124 | " \n",
1125 | " | 17 | \n",
1126 | " 18 | \n",
1127 | " NaN | \n",
1128 | " DEV | \n",
1129 | " SURAT | \n",
1130 | " BUS | \n",
1131 | " 500 | \n",
1132 | "
\n",
1133 | " \n",
1134 | " | 4 | \n",
1135 | " 5 | \n",
1136 | " BCA | \n",
1137 | " AMAN | \n",
1138 | " BARDOLI | \n",
1139 | " BUS | \n",
1140 | " 25 | \n",
1141 | "
\n",
1142 | " \n",
1143 | " | 19 | \n",
1144 | " 20 | \n",
1145 | " BCA | \n",
1146 | " ANZAR | \n",
1147 | " BARDOLI | \n",
1148 | " BUS | \n",
1149 | " 30 | \n",
1150 | "
\n",
1151 | " \n",
1152 | " | 5 | \n",
1153 | " 6 | \n",
1154 | " BCA | \n",
1155 | " CHMAN | \n",
1156 | " VESU | \n",
1157 | " CAR | \n",
1158 | " 100 | \n",
1159 | "
\n",
1160 | " \n",
1161 | " | 7 | \n",
1162 | " 8 | \n",
1163 | " BCA | \n",
1164 | " ABC | \n",
1165 | " VESU | \n",
1166 | " CAR | \n",
1167 | " 100 | \n",
1168 | "
\n",
1169 | " \n",
1170 | " | 18 | \n",
1171 | " 19 | \n",
1172 | " BBA | \n",
1173 | " SMIT | \n",
1174 | " BARDOLI | \n",
1175 | " CAR | \n",
1176 | " 70 | \n",
1177 | "
\n",
1178 | " \n",
1179 | " | 3 | \n",
1180 | " 4 | \n",
1181 | " BCA | \n",
1182 | " LAMAN | \n",
1183 | " SURAT | \n",
1184 | " CAR | \n",
1185 | " 100 | \n",
1186 | "
\n",
1187 | " \n",
1188 | " | 2 | \n",
1189 | " 3 | \n",
1190 | " BCA | \n",
1191 | " AXMAN | \n",
1192 | " VESU | \n",
1193 | " CAR | \n",
1194 | " 100 | \n",
1195 | "
\n",
1196 | " \n",
1197 | " | 14 | \n",
1198 | " 15 | \n",
1199 | " BCA | \n",
1200 | " RAMA | \n",
1201 | " VESU | \n",
1202 | " CAR | \n",
1203 | " 100 | \n",
1204 | "
\n",
1205 | " \n",
1206 | "
\n",
1207 | "
"
1208 | ],
1209 | "text/plain": [
1210 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
1211 | "0 1 BCA LAXMAN SURAT BIKE 50\n",
1212 | "16 17 BCA MEET NaN BIKE 10\n",
1213 | "12 13 NaN OM BARDOLI BIKE 50\n",
1214 | "10 11 BCA CDN VESU BIKE 50\n",
1215 | "9 10 BCA MNO BARDOLI BIKE 50\n",
1216 | "6 7 BCA MAN BARDOLI BUS 20\n",
1217 | "8 9 BCA XYZ SURAT BUS 20\n",
1218 | "11 12 BBA SRM BARDOLI BUS 20\n",
1219 | "13 14 BBA SAI SURAT BUS 20\n",
1220 | "15 16 BCA AYUSH BARDOLI BUS 40\n",
1221 | "1 2 BCA XMAN BARDOLI BUS 25\n",
1222 | "17 18 NaN DEV SURAT BUS 500\n",
1223 | "4 5 BCA AMAN BARDOLI BUS 25\n",
1224 | "19 20 BCA ANZAR BARDOLI BUS 30\n",
1225 | "5 6 BCA CHMAN VESU CAR 100\n",
1226 | "7 8 BCA ABC VESU CAR 100\n",
1227 | "18 19 BBA SMIT BARDOLI CAR 70\n",
1228 | "3 4 BCA LAMAN SURAT CAR 100\n",
1229 | "2 3 BCA AXMAN VESU CAR 100\n",
1230 | "14 15 BCA RAMA VESU CAR 100"
1231 | ]
1232 | },
1233 | "execution_count": 79,
1234 | "metadata": {},
1235 | "output_type": "execute_result"
1236 | }
1237 | ],
1238 | "source": [
1239 | "df.sort_values(by='TRAVEL_BY')"
1240 | ]
1241 | },
1242 | {
1243 | "cell_type": "markdown",
1244 | "id": "56424817",
1245 | "metadata": {},
1246 | "source": [
1247 | "# 9. Display those records who travel from “Bardoli” in “Bike”"
1248 | ]
1249 | },
1250 | {
1251 | "cell_type": "code",
1252 | "execution_count": 80,
1253 | "id": "b14572ad",
1254 | "metadata": {},
1255 | "outputs": [
1256 | {
1257 | "data": {
1258 | "text/html": [
1259 | "\n",
1260 | "\n",
1273 | "
\n",
1274 | " \n",
1275 | " \n",
1276 | " | \n",
1277 | " SID | \n",
1278 | " COURSE | \n",
1279 | " SNAME | \n",
1280 | " CITY | \n",
1281 | " TRAVEL_BY | \n",
1282 | " TRAVEL_EXPENSE | \n",
1283 | "
\n",
1284 | " \n",
1285 | " \n",
1286 | " \n",
1287 | " | 9 | \n",
1288 | " 10 | \n",
1289 | " BCA | \n",
1290 | " MNO | \n",
1291 | " BARDOLI | \n",
1292 | " BIKE | \n",
1293 | " 50 | \n",
1294 | "
\n",
1295 | " \n",
1296 | " | 12 | \n",
1297 | " 13 | \n",
1298 | " NaN | \n",
1299 | " OM | \n",
1300 | " BARDOLI | \n",
1301 | " BIKE | \n",
1302 | " 50 | \n",
1303 | "
\n",
1304 | " \n",
1305 | "
\n",
1306 | "
"
1307 | ],
1308 | "text/plain": [
1309 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
1310 | "9 10 BCA MNO BARDOLI BIKE 50\n",
1311 | "12 13 NaN OM BARDOLI BIKE 50"
1312 | ]
1313 | },
1314 | "execution_count": 80,
1315 | "metadata": {},
1316 | "output_type": "execute_result"
1317 | }
1318 | ],
1319 | "source": [
1320 | "df[(df['CITY']=='BARDOLI') & (df['TRAVEL_BY']=='BIKE')]"
1321 | ]
1322 | },
1323 | {
1324 | "cell_type": "markdown",
1325 | "id": "293bd44c",
1326 | "metadata": {},
1327 | "source": [
1328 | "# 10. How many students travel by bus, bike and car?"
1329 | ]
1330 | },
1331 | {
1332 | "cell_type": "code",
1333 | "execution_count": 89,
1334 | "id": "2598c89d",
1335 | "metadata": {},
1336 | "outputs": [
1337 | {
1338 | "data": {
1339 | "text/html": [
1340 | "\n",
1341 | "\n",
1354 | "
\n",
1355 | " \n",
1356 | " \n",
1357 | " | \n",
1358 | " TRAVEL_BY | \n",
1359 | " Number of Student | \n",
1360 | "
\n",
1361 | " \n",
1362 | " \n",
1363 | " \n",
1364 | " | 0 | \n",
1365 | " BIKE | \n",
1366 | " 5 | \n",
1367 | "
\n",
1368 | " \n",
1369 | " | 1 | \n",
1370 | " BUS | \n",
1371 | " 9 | \n",
1372 | "
\n",
1373 | " \n",
1374 | " | 2 | \n",
1375 | " CAR | \n",
1376 | " 6 | \n",
1377 | "
\n",
1378 | " \n",
1379 | "
\n",
1380 | "
"
1381 | ],
1382 | "text/plain": [
1383 | " TRAVEL_BY Number of Student\n",
1384 | "0 BIKE 5\n",
1385 | "1 BUS 9\n",
1386 | "2 CAR 6"
1387 | ]
1388 | },
1389 | "execution_count": 89,
1390 | "metadata": {},
1391 | "output_type": "execute_result"
1392 | }
1393 | ],
1394 | "source": [
1395 | "df.groupby(['TRAVEL_BY']).size().reset_index(name='Number of Student')"
1396 | ]
1397 | },
1398 | {
1399 | "cell_type": "markdown",
1400 | "id": "5aa2f6fd",
1401 | "metadata": {},
1402 | "source": [
1403 | "# 11. Display only city name. [ don’t repeat city name ]."
1404 | ]
1405 | },
1406 | {
1407 | "cell_type": "code",
1408 | "execution_count": 96,
1409 | "id": "260299cf",
1410 | "metadata": {},
1411 | "outputs": [
1412 | {
1413 | "data": {
1414 | "text/plain": [
1415 | "array(['SURAT', 'BARDOLI', 'VESU', nan], dtype=object)"
1416 | ]
1417 | },
1418 | "execution_count": 96,
1419 | "metadata": {},
1420 | "output_type": "execute_result"
1421 | }
1422 | ],
1423 | "source": [
1424 | "df['CITY'].unique()"
1425 | ]
1426 | },
1427 | {
1428 | "cell_type": "markdown",
1429 | "id": "6d215a02",
1430 | "metadata": {},
1431 | "source": [
1432 | "# 12. Display SNAME and TRAVEL BY columns data only."
1433 | ]
1434 | },
1435 | {
1436 | "cell_type": "code",
1437 | "execution_count": 98,
1438 | "id": "be753ee3",
1439 | "metadata": {},
1440 | "outputs": [
1441 | {
1442 | "data": {
1443 | "text/html": [
1444 | "\n",
1445 | "\n",
1458 | "
\n",
1459 | " \n",
1460 | " \n",
1461 | " | \n",
1462 | " SNAME | \n",
1463 | " TRAVEL_BY | \n",
1464 | "
\n",
1465 | " \n",
1466 | " \n",
1467 | " \n",
1468 | " | 0 | \n",
1469 | " LAXMAN | \n",
1470 | " BIKE | \n",
1471 | "
\n",
1472 | " \n",
1473 | " | 1 | \n",
1474 | " XMAN | \n",
1475 | " BUS | \n",
1476 | "
\n",
1477 | " \n",
1478 | " | 2 | \n",
1479 | " AXMAN | \n",
1480 | " CAR | \n",
1481 | "
\n",
1482 | " \n",
1483 | " | 3 | \n",
1484 | " LAMAN | \n",
1485 | " CAR | \n",
1486 | "
\n",
1487 | " \n",
1488 | " | 4 | \n",
1489 | " AMAN | \n",
1490 | " BUS | \n",
1491 | "
\n",
1492 | " \n",
1493 | " | 5 | \n",
1494 | " CHMAN | \n",
1495 | " CAR | \n",
1496 | "
\n",
1497 | " \n",
1498 | " | 6 | \n",
1499 | " MAN | \n",
1500 | " BUS | \n",
1501 | "
\n",
1502 | " \n",
1503 | " | 7 | \n",
1504 | " ABC | \n",
1505 | " CAR | \n",
1506 | "
\n",
1507 | " \n",
1508 | " | 8 | \n",
1509 | " XYZ | \n",
1510 | " BUS | \n",
1511 | "
\n",
1512 | " \n",
1513 | " | 9 | \n",
1514 | " MNO | \n",
1515 | " BIKE | \n",
1516 | "
\n",
1517 | " \n",
1518 | " | 10 | \n",
1519 | " CDN | \n",
1520 | " BIKE | \n",
1521 | "
\n",
1522 | " \n",
1523 | " | 11 | \n",
1524 | " SRM | \n",
1525 | " BUS | \n",
1526 | "
\n",
1527 | " \n",
1528 | " | 12 | \n",
1529 | " OM | \n",
1530 | " BIKE | \n",
1531 | "
\n",
1532 | " \n",
1533 | " | 13 | \n",
1534 | " SAI | \n",
1535 | " BUS | \n",
1536 | "
\n",
1537 | " \n",
1538 | " | 14 | \n",
1539 | " RAMA | \n",
1540 | " CAR | \n",
1541 | "
\n",
1542 | " \n",
1543 | " | 15 | \n",
1544 | " AYUSH | \n",
1545 | " BUS | \n",
1546 | "
\n",
1547 | " \n",
1548 | " | 16 | \n",
1549 | " MEET | \n",
1550 | " BIKE | \n",
1551 | "
\n",
1552 | " \n",
1553 | " | 17 | \n",
1554 | " DEV | \n",
1555 | " BUS | \n",
1556 | "
\n",
1557 | " \n",
1558 | " | 18 | \n",
1559 | " SMIT | \n",
1560 | " CAR | \n",
1561 | "
\n",
1562 | " \n",
1563 | " | 19 | \n",
1564 | " ANZAR | \n",
1565 | " BUS | \n",
1566 | "
\n",
1567 | " \n",
1568 | "
\n",
1569 | "
"
1570 | ],
1571 | "text/plain": [
1572 | " SNAME TRAVEL_BY\n",
1573 | "0 LAXMAN BIKE\n",
1574 | "1 XMAN BUS\n",
1575 | "2 AXMAN CAR\n",
1576 | "3 LAMAN CAR\n",
1577 | "4 AMAN BUS\n",
1578 | "5 CHMAN CAR\n",
1579 | "6 MAN BUS\n",
1580 | "7 ABC CAR\n",
1581 | "8 XYZ BUS\n",
1582 | "9 MNO BIKE\n",
1583 | "10 CDN BIKE\n",
1584 | "11 SRM BUS\n",
1585 | "12 OM BIKE\n",
1586 | "13 SAI BUS\n",
1587 | "14 RAMA CAR\n",
1588 | "15 AYUSH BUS\n",
1589 | "16 MEET BIKE\n",
1590 | "17 DEV BUS\n",
1591 | "18 SMIT CAR\n",
1592 | "19 ANZAR BUS"
1593 | ]
1594 | },
1595 | "execution_count": 98,
1596 | "metadata": {},
1597 | "output_type": "execute_result"
1598 | }
1599 | ],
1600 | "source": [
1601 | "df[['SNAME','TRAVEL_BY']]"
1602 | ]
1603 | },
1604 | {
1605 | "cell_type": "markdown",
1606 | "id": "cb5613d0",
1607 | "metadata": {},
1608 | "source": [
1609 | "# 13. Display those record where students are from “BBA” coming in “Car” and “Expense < 500”."
1610 | ]
1611 | },
1612 | {
1613 | "cell_type": "code",
1614 | "execution_count": 99,
1615 | "id": "7ecb7777",
1616 | "metadata": {},
1617 | "outputs": [
1618 | {
1619 | "data": {
1620 | "text/html": [
1621 | "\n",
1622 | "\n",
1635 | "
\n",
1636 | " \n",
1637 | " \n",
1638 | " | \n",
1639 | " SID | \n",
1640 | " COURSE | \n",
1641 | " SNAME | \n",
1642 | " CITY | \n",
1643 | " TRAVEL_BY | \n",
1644 | " TRAVEL_EXPENSE | \n",
1645 | "
\n",
1646 | " \n",
1647 | " \n",
1648 | " \n",
1649 | " | 18 | \n",
1650 | " 19 | \n",
1651 | " BBA | \n",
1652 | " SMIT | \n",
1653 | " BARDOLI | \n",
1654 | " CAR | \n",
1655 | " 70 | \n",
1656 | "
\n",
1657 | " \n",
1658 | "
\n",
1659 | "
"
1660 | ],
1661 | "text/plain": [
1662 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
1663 | "18 19 BBA SMIT BARDOLI CAR 70"
1664 | ]
1665 | },
1666 | "execution_count": 99,
1667 | "metadata": {},
1668 | "output_type": "execute_result"
1669 | }
1670 | ],
1671 | "source": [
1672 | "df[(df['COURSE']=='BBA') & (df['TRAVEL_BY']=='CAR') & (df['TRAVEL_EXPENSE']<500)]"
1673 | ]
1674 | },
1675 | {
1676 | "cell_type": "markdown",
1677 | "id": "9dd3d327",
1678 | "metadata": {},
1679 | "source": [
1680 | "# 14. Display records from 5 to 9."
1681 | ]
1682 | },
1683 | {
1684 | "cell_type": "code",
1685 | "execution_count": 104,
1686 | "id": "46fb5260",
1687 | "metadata": {},
1688 | "outputs": [
1689 | {
1690 | "data": {
1691 | "text/html": [
1692 | "\n",
1693 | "\n",
1706 | "
\n",
1707 | " \n",
1708 | " \n",
1709 | " | \n",
1710 | " SID | \n",
1711 | " COURSE | \n",
1712 | " SNAME | \n",
1713 | " CITY | \n",
1714 | " TRAVEL_BY | \n",
1715 | " TRAVEL_EXPENSE | \n",
1716 | "
\n",
1717 | " \n",
1718 | " \n",
1719 | " \n",
1720 | " | 4 | \n",
1721 | " 5 | \n",
1722 | " BCA | \n",
1723 | " AMAN | \n",
1724 | " BARDOLI | \n",
1725 | " BUS | \n",
1726 | " 25 | \n",
1727 | "
\n",
1728 | " \n",
1729 | " | 5 | \n",
1730 | " 6 | \n",
1731 | " BCA | \n",
1732 | " CHMAN | \n",
1733 | " VESU | \n",
1734 | " CAR | \n",
1735 | " 100 | \n",
1736 | "
\n",
1737 | " \n",
1738 | " | 6 | \n",
1739 | " 7 | \n",
1740 | " BCA | \n",
1741 | " MAN | \n",
1742 | " BARDOLI | \n",
1743 | " BUS | \n",
1744 | " 20 | \n",
1745 | "
\n",
1746 | " \n",
1747 | " | 7 | \n",
1748 | " 8 | \n",
1749 | " BCA | \n",
1750 | " ABC | \n",
1751 | " VESU | \n",
1752 | " CAR | \n",
1753 | " 100 | \n",
1754 | "
\n",
1755 | " \n",
1756 | " | 8 | \n",
1757 | " 9 | \n",
1758 | " BCA | \n",
1759 | " XYZ | \n",
1760 | " SURAT | \n",
1761 | " BUS | \n",
1762 | " 20 | \n",
1763 | "
\n",
1764 | " \n",
1765 | "
\n",
1766 | "
"
1767 | ],
1768 | "text/plain": [
1769 | " SID COURSE SNAME CITY TRAVEL_BY TRAVEL_EXPENSE\n",
1770 | "4 5 BCA AMAN BARDOLI BUS 25\n",
1771 | "5 6 BCA CHMAN VESU CAR 100\n",
1772 | "6 7 BCA MAN BARDOLI BUS 20\n",
1773 | "7 8 BCA ABC VESU CAR 100\n",
1774 | "8 9 BCA XYZ SURAT BUS 20"
1775 | ]
1776 | },
1777 | "execution_count": 104,
1778 | "metadata": {},
1779 | "output_type": "execute_result"
1780 | }
1781 | ],
1782 | "source": [
1783 | "df[4:9]"
1784 | ]
1785 | },
1786 | {
1787 | "cell_type": "markdown",
1788 | "id": "f409ec68",
1789 | "metadata": {},
1790 | "source": [
1791 | "# 15. Display student name and city of “BCA” department from records 11 to 15."
1792 | ]
1793 | },
1794 | {
1795 | "cell_type": "code",
1796 | "execution_count": 122,
1797 | "id": "b05fd676",
1798 | "metadata": {},
1799 | "outputs": [
1800 | {
1801 | "data": {
1802 | "text/html": [
1803 | "\n",
1804 | "\n",
1817 | "
\n",
1818 | " \n",
1819 | " \n",
1820 | " | \n",
1821 | " SNAME | \n",
1822 | " CITY | \n",
1823 | "
\n",
1824 | " \n",
1825 | " \n",
1826 | " \n",
1827 | " | 10 | \n",
1828 | " CDN | \n",
1829 | " VESU | \n",
1830 | "
\n",
1831 | " \n",
1832 | " | 14 | \n",
1833 | " RAMA | \n",
1834 | " VESU | \n",
1835 | "
\n",
1836 | " \n",
1837 | "
\n",
1838 | "
"
1839 | ],
1840 | "text/plain": [
1841 | " SNAME CITY\n",
1842 | "10 CDN VESU\n",
1843 | "14 RAMA VESU"
1844 | ]
1845 | },
1846 | "execution_count": 122,
1847 | "metadata": {},
1848 | "output_type": "execute_result"
1849 | }
1850 | ],
1851 | "source": [
1852 | "df1=df.iloc[10:15,0:]\n",
1853 | "df1[['SNAME','CITY']] [df1['COURSE'] == 'BCA']"
1854 | ]
1855 | }
1856 | ],
1857 | "metadata": {
1858 | "kernelspec": {
1859 | "display_name": "Python 3 (ipykernel)",
1860 | "language": "python",
1861 | "name": "python3"
1862 | },
1863 | "language_info": {
1864 | "codemirror_mode": {
1865 | "name": "ipython",
1866 | "version": 3
1867 | },
1868 | "file_extension": ".py",
1869 | "mimetype": "text/x-python",
1870 | "name": "python",
1871 | "nbconvert_exporter": "python",
1872 | "pygments_lexer": "ipython3",
1873 | "version": "3.10.6"
1874 | }
1875 | },
1876 | "nbformat": 4,
1877 | "nbformat_minor": 5
1878 | }
1879 |
--------------------------------------------------------------------------------