PW Akshay

Generation

generate functionFri, 02 Dec 2022

Create a student table and insert data. Implement the following SQL commands on the student table: o ALTER table to add new attributes / modify data type / drop attribute o UPDATE table to modify data o ORDER By to display data in ascending / descending order o DELETE to remove tuple(s) o GROUP BY and find the min, max, sum, count and average

import pandas as pd student = pd.DataFrame({ 'ID': [1, 2, 3, 4, 5, 6], 'Name': ['A', 'B', 'C', 'D', 'E', 'F'], 'Gender': ['M', 'F', 'M', 'M', 'F', 'M'], 'Age': [18, 19, 20, 21, 22, 23], 'Grade': [2, 1, 4, 3, 2, 4] }) # ALTER table to add new attributes / modify data type / drop attribute student['City'] = ['B', 'A', 'C', 'A', 'B', 'C'] student['Grade'] = student['Grade'].astype('category') student.drop(['City'], axis=1) # UPDATE table to modify data student['Name'] = ['AA', 'BB', 'CC', 'DD', 'EE', 'FF'] student['Gender'] = 'M' student.loc[student['ID'] = 1, 'Grade'] = 2

Questions about programming?Chat with your personal AI assistant