Informatics Practices
Consider the DataFrame df shown below.
MovieID | Title | Year | Rating | |
---|---|---|---|---|
0 | 1 | LAGAAN | 2001 | 8.4 |
1 | 2 | TAARE ZAMEEN PAR | 2007 | 8.5 |
2 | 3 | 3 IDIOTS | 2009 | 8.4 |
3 | 4 | DANGAL | 2016 | 8.4 |
4 | 5 | ANDHADHUN | 2018 | 8.3 |
Write Python statements for the DataFrame df to:
I. Print the first two rows of the DataFrame df.
II. Display titles of all the movies.
III. Remove the column rating.
IV. Display the data of the 'Title' column from indexes 2 to 4 (both included)
V. Rename the column name 'Title' to 'Name'.
Python Pandas
1 Like
Answer
I. print(df.head(2))
II. print(df['Title'])
III. df = df.drop(‘Rating’, axis=1)
IV. print(df.loc[2:4,'Title'])
V. df.rename(columns={'Title':'Name'}, inplace=True)
Answered By
3 Likes
Related Questions
Dr. Kavita has created a database for a hospital's pharmacy. The database includes a table named MEDICINE whose column (attribute) names are mentioned below:
MID: Shows the unique code for each medicine.
MED_NAME: Specifies the medicine name.
SUPP_CITY: Specifies the city where the supplier is located.
STOCK: Indicates the quantity of medicine available.
DEL_DATE: Specifies the date when the medicine was delivered.
Table: MEDICINE
MID MED_NAME SUPP_CITY STOCK DEL_DATE M01 PARACETAMOL MUMBAI 200 2023-06-15 M02 AMOXICILLIN KOLKATA 50 2023-03-21 M03 COUGH SYRUP BENGALURU 120 2023-02-10 M04 INSULIN CHENNAI 135 2023-01-25 M05 IBUPROFEN AHMEDABAD 30 2023-04-05 Write the output of the following SQL Queries.
I. Select LENGTH(MED_NAME) from MEDICINE where STOCK > 100;
II. Select MED_NAME from MEDICINE where month(DEL_DATE) = 4;
III. Select MED_NAME from MEDICINE where STOCK between 120 and 200;
IV. Select max(DEL_DATE) from MEDICINE;
ABC Pvt. Ltd., a multinational technology company, is looking to establish its Indian Head Office in Bengaluru, and a regional office branch in Lucknow. The Bengaluru head office will be organized into four departments: HR, FINANCE, TECHNICAL, AND SUPPORT. As a network engineer, you have to propose solutions for various queries listed from I to V.
The shortest distances between the departments/offices are as follows:
HR TO FINANCE 65 M HR TO TECHNICAL 80 M HR TO SUPPORT 70 M FINANCE TO TECHNICAL 60 M FINANCE TO SUPPORT 75 M TECHNICAL TO SUPPORT 50 M BENGALURU OFFICE TO LUCKNOW 1900 KM The number of computers in each department/office is as follows:
HR 175 FINANCE 35 TECHNICAL 50 SUPPORT 15 LUCKNOW OFFICE 40 I. Suggest the most suitable department in the Bengaluru Office Setup, to install the server. Also, give a reason to justify your suggested location.
II. Draw a suitable cable layout of wired network connectivity between the departments in the Bengaluru Office.
III. Which networking device would you suggest the company to purchase to interconnect all the computers within a department in Bengaluru Office?
IV. The company is considering establishing a network connection between its Bengaluru Head Office and Lucknow regional office. Which type of network—LAN, MAN, or WAN—will be created? Justify your answer.
V. The company plans to develop an interactive website that will enable its employees to monitor their performance after login. Would you recommend a static or dynamic website, and why?
Write suitable SQL query for the following:
I. To display the average score from the test_results column (attribute) in the Exams table.
II. To display the last three characters of the registration_number column (attribute) in the Vehicles table. (Note: The registration numbers are stored in the format DL-01-AV-1234)
III. To display the data from the column (attribute) username in the Users table, after eliminating any leading and trailing spaces.
IV. To display the maximum value in the salary column (attribute) of the Employees table.
V. To determine the count of rows in the Suppliers table.
Write suitable SQL query for the following:
I. Round the value of pi (3.14159) to two decimal places.
II. Calculate the remainder when 125 is divided by 8.
III. Display the number of characters in the word 'NewDelhi'.
IV. Display the first 5 characters from the word 'Informatics Practices'.
V. Display details from 'email' column (attribute), in the 'Students' table, after removing any leading and trailing spaces.