Question: Actions Implement the PROJECT operator. project (relation, column_list) Performs Projection on a given relation Parameters: relation: Table Object, the relation to be manipulated columns: list
Actions Implement the PROJECT operator. project (relation, column_list)
Performs Projection on a given relation Parameters: relation: Table Object, the relation to be manipulated columns: list of str, list of column names to be projected Returns: Table Object, the projected relation Make sure the column names in the input columns exist in the relation. Otherwise, print error message "Key(s) in column does not exist in the relation!" and return None. Project operator function should return distinct records. DO NOT use pandas methods to construct operator function. You can use: python's list/dictionary manipulation the utility functions provided above other relational operators implemented in this notebook Columns in result/output can be displayed in any order.
def project(relation: Table, columns: list) -> Table: """ Performs project on a given relation :param relation: Table Object, the table to be manipulated :param columns: list of str, list of column names to be projected :return: Table Object, the projected relation """ projected_relation = Table("Project_Relation")
# Enter your code below
return projected_relation
#Test Fuction R = project(bars, ["owner", "name"]) view_table(R)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
