Project Operation ( P ) in Python
The Project operation selects columns that are given as input.
Let us understand the PROJECT operation better using some examples.
Consider the following table:
R1 : FACULTY-1
FNo | FName | DNo | Qual | Salary |
22 | Riya | 21 | Ph.D | 55000 |
24 | Priya | 22 | M. Tech | 50000 |
25 | Zayn | 22 | M. Tech | 42000 |
27 | Harry | 23 | M. Tech | 28000 |
30 | Sia | 23 | M. Tech | 32000 |
33 | Max | 24 | Ph.D | 53000 |
35 | Fred | 24 | Ph.D | 52000 |
37 | Diva | 25 | M. Tech | 26000 |
39 | Ben | 25 | M. Tech | 24000 |
40 | Trent | 25 | M. Tech | 34000 |
Example-1 : Find the list of FName and their salaries..
FName, Salary (Faculty-1)
Output:
FName | Salary |
Riya | 55000 |
Priya | 50000 |
Zayn | 42000 |
Harry | 28000 |
Sia | 32000 |
Max | 53000 |
Fred | 52000 |
Diva | 26000 |
Ben | 24000 |
Trent | 34000 |
Example-2 : Find the list of Qualifications.
P Qual (Faculty-1)
Output :
Qual |
Ph.D |
M.Tech |
Example-3 : Find the list of Faculty having Ph.D. Qualification.
P FName (squal = ‘Ph.D.’ ( (Faculty-1) )
Output :
Qual |
Riya |
Max |
Fred |
Example-4 : Find the Salaries of Faculty along with their names having
MTech qualification.
P FName, Salary (squal = ‘MTech’ ( (Faculty-1) )
Output :
FName | Qual |
Priya | 50000 |
Zayn | 42000 |
Harry | 28000 |
Sia | 32000 |
Diva | 26000 |
Ben | 24000 |
Trent | 34000 |