├── .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 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | "
StudentCityAge
0RutvikPune22
1PanktiDelhi16
2EvaanSurat5
3DhyanHouston13
\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 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
01BCALAXMANSURATBIKE50
12BCAXMANBARDOLIBUS25
23BCAAXMANVESUCAR100
34BCALAMANSURATCAR100
45BCAAMANBARDOLIBUS25
56BCACHMANVESUCAR100
67BCAMANBARDOLIBUS20
78BCAABCVESUCAR100
89BCAXYZSURATBUS20
910BCAMNOBARDOLIBIKE50
1011BCACDNVESUBIKE50
1112BBASRMBARDOLIBUS20
1213NaNOMBARDOLIBIKE50
1314BBASAISURATBUS20
1415BCARAMAVESUCAR100
1516BCAAYUSHBARDOLIBUS40
1617BCAMEETNaNBIKE10
1718NaNDEVSURATBUS500
1819BBASMITBARDOLICAR70
1920BCAANZARBARDOLIBUS30
\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 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | " \n", 397 | " \n", 398 | " \n", 399 | " \n", 400 | " \n", 401 | " \n", 402 | " \n", 403 | " \n", 404 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
01BCALAXMANSURATBIKE50
12BCAXMANBARDOLIBUS25
\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 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 488 | " \n", 489 | " \n", 490 | " \n", 491 | " \n", 492 | " \n", 493 | " \n", 494 | " \n", 495 | " \n", 496 | " \n", 497 | " \n", 498 | " \n", 499 | " \n", 500 | " \n", 501 | " \n", 502 | " \n", 503 | " \n", 504 | " \n", 505 | " \n", 506 | " \n", 507 | " \n", 508 | " \n", 509 | " \n", 510 | " \n", 511 | " \n", 512 | " \n", 513 | " \n", 514 | " \n", 515 | " \n", 516 | " \n", 517 | " \n", 518 | " \n", 519 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | " \n", 531 | " \n", 532 | " \n", 533 | " \n", 534 | " \n", 535 | " \n", 536 | " \n", 537 | " \n", 538 | " \n", 539 | " \n", 540 | " \n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | " \n", 547 | " \n", 548 | " \n", 549 | " \n", 550 | " \n", 551 | " \n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | " \n", 605 | " \n", 606 | " \n", 607 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
01BCALAXMANSURATBIKE50
12BCAXMANBARDOLIBUS25
23BCAAXMANVESUCAR100
34BCALAMANSURATCAR100
45BCAAMANBARDOLIBUS25
56BCACHMANVESUCAR100
67BCAMANBARDOLIBUS20
78BCAABCVESUCAR100
89BCAXYZSURATBUS20
910BCAMNOBARDOLIBIKE50
1011BCACDNVESUBIKE50
1112BBASRMBARDOLIBUS20
1213NaNOMBARDOLIBIKE50
1314BBASAISURATBUS20
1415BCARAMAVESUCAR100
\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 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | " \n", 701 | " \n", 702 | " \n", 703 | " \n", 704 | " \n", 705 | " \n", 706 | " \n", 707 | " \n", 708 | " \n", 709 | " \n", 710 | " \n", 711 | " \n", 712 | " \n", 713 | " \n", 714 | " \n", 715 | " \n", 716 | " \n", 717 | " \n", 718 | " \n", 719 | " \n", 720 | " \n", 721 | " \n", 722 | " \n", 723 | " \n", 724 | " \n", 725 | " \n", 726 | " \n", 727 | " \n", 728 | " \n", 729 | " \n", 730 | " \n", 731 | " \n", 732 | " \n", 733 | " \n", 734 | " \n", 735 | " \n", 736 | " \n", 737 | " \n", 738 | " \n", 739 | " \n", 740 | " \n", 741 | " \n", 742 | " \n", 743 | " \n", 744 | " \n", 745 | " \n", 746 | " \n", 747 | " \n", 748 | " \n", 749 | " \n", 750 | " \n", 751 | " \n", 752 | " \n", 753 | " \n", 754 | " \n", 755 | " \n", 756 | " \n", 757 | " \n", 758 | " \n", 759 | " \n", 760 | " \n", 761 | " \n", 762 | " \n", 763 | " \n", 764 | " \n", 765 | " \n", 766 | " \n", 767 | " \n", 768 | " \n", 769 | " \n", 770 | " \n", 771 | " \n", 772 | " \n", 773 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
1011BCACDNVESUBIKE50
1112BBASRMBARDOLIBUS20
1213NaNOMBARDOLIBIKE50
1314BBASAISURATBUS20
1415BCARAMAVESUCAR100
1516BCAAYUSHBARDOLIBUS40
1617BCAMEETNaNBIKE10
1718NaNDEVSURATBUS500
1819BBASMITBARDOLICAR70
1920BCAANZARBARDOLIBUS30
\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 | " \n", 836 | " \n", 837 | " \n", 838 | " \n", 839 | " \n", 840 | " \n", 841 | " \n", 842 | " \n", 843 | " \n", 844 | " \n", 845 | " \n", 846 | " \n", 847 | " \n", 848 | " \n", 849 | " \n", 850 | " \n", 851 | " \n", 852 | " \n", 853 | " \n", 854 | " \n", 855 | " \n", 856 | " \n", 857 | " \n", 858 | " \n", 859 | " \n", 860 | " \n", 861 | " \n", 862 | " \n", 863 | " \n", 864 | " \n", 865 | " \n", 866 | " \n", 867 | " \n", 868 | " \n", 869 | " \n", 870 | " \n", 871 | " \n", 872 | " \n", 873 | " \n", 874 | " \n", 875 | " \n", 876 | " \n", 877 | " \n", 878 | " \n", 879 | " \n", 880 | " \n", 881 | " \n", 882 | " \n", 883 | " \n", 884 | " \n", 885 | " \n", 886 | " \n", 887 | " \n", 888 | " \n", 889 | " \n", 890 | " \n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | "
SIDTRAVEL_EXPENSE
CITYSNAME
BARDOLIAMAN525
ANZAR2030
AYUSH1640
MAN720
MNO1050
OM1350
SMIT1970
SRM1220
XMAN225
SURATDEV18500
LAMAN4100
LAXMAN150
SAI1420
XYZ920
VESUABC8100
AXMAN3100
CDN1150
CHMAN6100
RAMA15100
\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 | " \n", 1017 | " \n", 1018 | " \n", 1019 | " \n", 1020 | " \n", 1021 | " \n", 1022 | " \n", 1023 | " \n", 1024 | " \n", 1025 | " \n", 1026 | " \n", 1027 | " \n", 1028 | " \n", 1029 | " \n", 1030 | " \n", 1031 | " \n", 1032 | " \n", 1033 | " \n", 1034 | " \n", 1035 | " \n", 1036 | " \n", 1037 | " \n", 1038 | " \n", 1039 | " \n", 1040 | " \n", 1041 | " \n", 1042 | " \n", 1043 | " \n", 1044 | " \n", 1045 | " \n", 1046 | " \n", 1047 | " \n", 1048 | " \n", 1049 | " \n", 1050 | " \n", 1051 | " \n", 1052 | " \n", 1053 | " \n", 1054 | " \n", 1055 | " \n", 1056 | " \n", 1057 | " \n", 1058 | " \n", 1059 | " \n", 1060 | " \n", 1061 | " \n", 1062 | " \n", 1063 | " \n", 1064 | " \n", 1065 | " \n", 1066 | " \n", 1067 | " \n", 1068 | " \n", 1069 | " \n", 1070 | " \n", 1071 | " \n", 1072 | " \n", 1073 | " \n", 1074 | " \n", 1075 | " \n", 1076 | " \n", 1077 | " \n", 1078 | " \n", 1079 | " \n", 1080 | " \n", 1081 | " \n", 1082 | " \n", 1083 | " \n", 1084 | " \n", 1085 | " \n", 1086 | " \n", 1087 | " \n", 1088 | " \n", 1089 | " \n", 1090 | " \n", 1091 | " \n", 1092 | " \n", 1093 | " \n", 1094 | " \n", 1095 | " \n", 1096 | " \n", 1097 | " \n", 1098 | " \n", 1099 | " \n", 1100 | " \n", 1101 | " \n", 1102 | " \n", 1103 | " \n", 1104 | " \n", 1105 | " \n", 1106 | " \n", 1107 | " \n", 1108 | " \n", 1109 | " \n", 1110 | " \n", 1111 | " \n", 1112 | " \n", 1113 | " \n", 1114 | " \n", 1115 | " \n", 1116 | " \n", 1117 | " \n", 1118 | " \n", 1119 | " \n", 1120 | " \n", 1121 | " \n", 1122 | " \n", 1123 | " \n", 1124 | " \n", 1125 | " \n", 1126 | " \n", 1127 | " \n", 1128 | " \n", 1129 | " \n", 1130 | " \n", 1131 | " \n", 1132 | " \n", 1133 | " \n", 1134 | " \n", 1135 | " \n", 1136 | " \n", 1137 | " \n", 1138 | " \n", 1139 | " \n", 1140 | " \n", 1141 | " \n", 1142 | " \n", 1143 | " \n", 1144 | " \n", 1145 | " \n", 1146 | " \n", 1147 | " \n", 1148 | " \n", 1149 | " \n", 1150 | " \n", 1151 | " \n", 1152 | " \n", 1153 | " \n", 1154 | " \n", 1155 | " \n", 1156 | " \n", 1157 | " \n", 1158 | " \n", 1159 | " \n", 1160 | " \n", 1161 | " \n", 1162 | " \n", 1163 | " \n", 1164 | " \n", 1165 | " \n", 1166 | " \n", 1167 | " \n", 1168 | " \n", 1169 | " \n", 1170 | " \n", 1171 | " \n", 1172 | " \n", 1173 | " \n", 1174 | " \n", 1175 | " \n", 1176 | " \n", 1177 | " \n", 1178 | " \n", 1179 | " \n", 1180 | " \n", 1181 | " \n", 1182 | " \n", 1183 | " \n", 1184 | " \n", 1185 | " \n", 1186 | " \n", 1187 | " \n", 1188 | " \n", 1189 | " \n", 1190 | " \n", 1191 | " \n", 1192 | " \n", 1193 | " \n", 1194 | " \n", 1195 | " \n", 1196 | " \n", 1197 | " \n", 1198 | " \n", 1199 | " \n", 1200 | " \n", 1201 | " \n", 1202 | " \n", 1203 | " \n", 1204 | " \n", 1205 | " \n", 1206 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
01BCALAXMANSURATBIKE50
1617BCAMEETNaNBIKE10
1213NaNOMBARDOLIBIKE50
1011BCACDNVESUBIKE50
910BCAMNOBARDOLIBIKE50
67BCAMANBARDOLIBUS20
89BCAXYZSURATBUS20
1112BBASRMBARDOLIBUS20
1314BBASAISURATBUS20
1516BCAAYUSHBARDOLIBUS40
12BCAXMANBARDOLIBUS25
1718NaNDEVSURATBUS500
45BCAAMANBARDOLIBUS25
1920BCAANZARBARDOLIBUS30
56BCACHMANVESUCAR100
78BCAABCVESUCAR100
1819BBASMITBARDOLICAR70
34BCALAMANSURATCAR100
23BCAAXMANVESUCAR100
1415BCARAMAVESUCAR100
\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 | " \n", 1278 | " \n", 1279 | " \n", 1280 | " \n", 1281 | " \n", 1282 | " \n", 1283 | " \n", 1284 | " \n", 1285 | " \n", 1286 | " \n", 1287 | " \n", 1288 | " \n", 1289 | " \n", 1290 | " \n", 1291 | " \n", 1292 | " \n", 1293 | " \n", 1294 | " \n", 1295 | " \n", 1296 | " \n", 1297 | " \n", 1298 | " \n", 1299 | " \n", 1300 | " \n", 1301 | " \n", 1302 | " \n", 1303 | " \n", 1304 | " \n", 1305 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
910BCAMNOBARDOLIBIKE50
1213NaNOMBARDOLIBIKE50
\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 | " \n", 1359 | " \n", 1360 | " \n", 1361 | " \n", 1362 | " \n", 1363 | " \n", 1364 | " \n", 1365 | " \n", 1366 | " \n", 1367 | " \n", 1368 | " \n", 1369 | " \n", 1370 | " \n", 1371 | " \n", 1372 | " \n", 1373 | " \n", 1374 | " \n", 1375 | " \n", 1376 | " \n", 1377 | " \n", 1378 | " \n", 1379 | "
TRAVEL_BYNumber of Student
0BIKE5
1BUS9
2CAR6
\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 | " \n", 1463 | " \n", 1464 | " \n", 1465 | " \n", 1466 | " \n", 1467 | " \n", 1468 | " \n", 1469 | " \n", 1470 | " \n", 1471 | " \n", 1472 | " \n", 1473 | " \n", 1474 | " \n", 1475 | " \n", 1476 | " \n", 1477 | " \n", 1478 | " \n", 1479 | " \n", 1480 | " \n", 1481 | " \n", 1482 | " \n", 1483 | " \n", 1484 | " \n", 1485 | " \n", 1486 | " \n", 1487 | " \n", 1488 | " \n", 1489 | " \n", 1490 | " \n", 1491 | " \n", 1492 | " \n", 1493 | " \n", 1494 | " \n", 1495 | " \n", 1496 | " \n", 1497 | " \n", 1498 | " \n", 1499 | " \n", 1500 | " \n", 1501 | " \n", 1502 | " \n", 1503 | " \n", 1504 | " \n", 1505 | " \n", 1506 | " \n", 1507 | " \n", 1508 | " \n", 1509 | " \n", 1510 | " \n", 1511 | " \n", 1512 | " \n", 1513 | " \n", 1514 | " \n", 1515 | " \n", 1516 | " \n", 1517 | " \n", 1518 | " \n", 1519 | " \n", 1520 | " \n", 1521 | " \n", 1522 | " \n", 1523 | " \n", 1524 | " \n", 1525 | " \n", 1526 | " \n", 1527 | " \n", 1528 | " \n", 1529 | " \n", 1530 | " \n", 1531 | " \n", 1532 | " \n", 1533 | " \n", 1534 | " \n", 1535 | " \n", 1536 | " \n", 1537 | " \n", 1538 | " \n", 1539 | " \n", 1540 | " \n", 1541 | " \n", 1542 | " \n", 1543 | " \n", 1544 | " \n", 1545 | " \n", 1546 | " \n", 1547 | " \n", 1548 | " \n", 1549 | " \n", 1550 | " \n", 1551 | " \n", 1552 | " \n", 1553 | " \n", 1554 | " \n", 1555 | " \n", 1556 | " \n", 1557 | " \n", 1558 | " \n", 1559 | " \n", 1560 | " \n", 1561 | " \n", 1562 | " \n", 1563 | " \n", 1564 | " \n", 1565 | " \n", 1566 | " \n", 1567 | " \n", 1568 | "
SNAMETRAVEL_BY
0LAXMANBIKE
1XMANBUS
2AXMANCAR
3LAMANCAR
4AMANBUS
5CHMANCAR
6MANBUS
7ABCCAR
8XYZBUS
9MNOBIKE
10CDNBIKE
11SRMBUS
12OMBIKE
13SAIBUS
14RAMACAR
15AYUSHBUS
16MEETBIKE
17DEVBUS
18SMITCAR
19ANZARBUS
\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 | " \n", 1640 | " \n", 1641 | " \n", 1642 | " \n", 1643 | " \n", 1644 | " \n", 1645 | " \n", 1646 | " \n", 1647 | " \n", 1648 | " \n", 1649 | " \n", 1650 | " \n", 1651 | " \n", 1652 | " \n", 1653 | " \n", 1654 | " \n", 1655 | " \n", 1656 | " \n", 1657 | " \n", 1658 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
1819BBASMITBARDOLICAR70
\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 | " \n", 1711 | " \n", 1712 | " \n", 1713 | " \n", 1714 | " \n", 1715 | " \n", 1716 | " \n", 1717 | " \n", 1718 | " \n", 1719 | " \n", 1720 | " \n", 1721 | " \n", 1722 | " \n", 1723 | " \n", 1724 | " \n", 1725 | " \n", 1726 | " \n", 1727 | " \n", 1728 | " \n", 1729 | " \n", 1730 | " \n", 1731 | " \n", 1732 | " \n", 1733 | " \n", 1734 | " \n", 1735 | " \n", 1736 | " \n", 1737 | " \n", 1738 | " \n", 1739 | " \n", 1740 | " \n", 1741 | " \n", 1742 | " \n", 1743 | " \n", 1744 | " \n", 1745 | " \n", 1746 | " \n", 1747 | " \n", 1748 | " \n", 1749 | " \n", 1750 | " \n", 1751 | " \n", 1752 | " \n", 1753 | " \n", 1754 | " \n", 1755 | " \n", 1756 | " \n", 1757 | " \n", 1758 | " \n", 1759 | " \n", 1760 | " \n", 1761 | " \n", 1762 | " \n", 1763 | " \n", 1764 | " \n", 1765 | "
SIDCOURSESNAMECITYTRAVEL_BYTRAVEL_EXPENSE
45BCAAMANBARDOLIBUS25
56BCACHMANVESUCAR100
67BCAMANBARDOLIBUS20
78BCAABCVESUCAR100
89BCAXYZSURATBUS20
\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 | " \n", 1822 | " \n", 1823 | " \n", 1824 | " \n", 1825 | " \n", 1826 | " \n", 1827 | " \n", 1828 | " \n", 1829 | " \n", 1830 | " \n", 1831 | " \n", 1832 | " \n", 1833 | " \n", 1834 | " \n", 1835 | " \n", 1836 | " \n", 1837 | "
SNAMECITY
10CDNVESU
14RAMAVESU
\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 | --------------------------------------------------------------------------------