Informatics Practices
Write a Python code to create a dataframe with appropriate headings from the list given below:
['S101', 'Amy', 70], ['S102', 'Bandhi', 69], ['S104', 'Cathy', 75], ['S105', 'Gundaho', 82]
Answer
import pandas as pd
data = [
['S101', 'Amy', 70],
['S102', 'Bandhi', 69],
['S104', 'Cathy', 75],
['S105', 'Gundaho', 82]
]
columns = ['ID', 'Name', 'Score']
df = pd.DataFrame(data, columns=columns)
print(df)
Output
ID Name Score
0 S101 Amy 70
1 S102 Bandhi 69
2 S104 Cathy 75
3 S105 Gundaho 82
Related Questions
What is Mathematical function in SQL? Name any two.
Mr. Sombuddha, an HR Manager in a multinational company "Star-X World", has created the following table to store the records of employees:
Table: Emp
Eid EName Department DOB DOJ Star1 Dev Sales 1994-08-28 2020-02-14 Star2 Melinda IT 1997-10-15 2021-11-19 Star3 Raj Accounts 1998-10-02 2019-04-02 Star4 Michael Sales 2000-02-17 2020-05-01 Star5 Sajal IT 2001-12-05 2018-06-13 Star6 John Accounts 1995-01-03 2019-07-15 Star7 Julia Sales 1985-11-13 2020-08-19 Predict the output of the following queries that he has written:
(i) Select max(year(DOB)) from emp;
(ii) Select ENAME from emp where month(DOJ) = 11;
(iii) Select length(EName) from emp where Department = "IT";
A relation Vehicles is given below:
V_no Type Company Price Qty AW125 WagonR Maruti 250000 25 J0083 Jeep Mahindra 4000000 15 S9090 SUV Mitsubishi 2500000 18 M0892 Mini van Datsun 1500000 26 W9760 SUV Maruti 2500000 18 R2409 Mini van Mahindra 350000 15 Write SQL commands to:
(i) Display the average price of each type of vehicle having a quantity of more than 20.
(ii) Count the type of vehicles manufactured by each company.
(iii) Display the total price of all types of vehicles.
What is the difference between the order by and group by clauses when used along with a select statement? Explain with an example.