[go: up one dir, main page]

0% found this document useful (0 votes)
28 views2 pages

PANDAS PRACTISE QUESTIONS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

PANDAS PRACTISE QUESTIONS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PANDAS PRACTISE QUESTIONS:

1. From the given dataset print the first and last five rows.
2. Clean the dataset and update the CSV file.
3. Find the most expensive car company name.
4. Print All Toyota Cars details.
5. Count total cars per company.
6. Find each company’s Highest price car.
7. Find the average mileage of each car making company
8. Sort all cars by Price column.
9. Concatenate two data frames using the following conditions.
GermanCars = {'Company': ['Ford', 'Mercedes', 'BMV', 'Audi'], 'Price':
[23845, 171995, 135925 , 71400]}
japaneseCars = {'Company': ['Toyota', 'Honda', 'Nissan', 'Mitsubishi '],
'Price': [29995, 23600, 61500 , 58900]}
10.Write a Pandas program to create a dataframe from a dictionary and
display it.
Sample data: {'X':[78,85,96,80,86], 'Y':[84,94,89,83,86],'Z':
[86,97,96,72,83]}
11. Write a Pandas program to create and display a DataFrame from a
specified dictionary data which has the index labels.
Sample Python dictionary data and list labels:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily',
'Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'].
12.Write a Pandas program to get the first 3 rows of a given DataFrame.
13.Write a Pandas program to select the 'name' and 'score' columns from
the following DataFrame.
14.Write a Pandas program to select the rows where the score is missing,
i.e. is NaN.

Sample DataFrame:
Sample Python dictionary data and list labels:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily',
'Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j'].
15.Write a Pandas program to select the rows the score is between 15 and
20 (inclusive).
Sample Python dictionary data and list labels:
16. Write a Pandas program to change the score in row 'd' to 11.5.
17. Write a Pandas program to calculate the sum of the examination
attempts by the students.
18.Write a Pandas program to calculate the mean of all students' scores.
Data is stored in a dataframe.
19.Write a Pandas program to sort the DataFrame first by 'name' in
descending order, then by 'score' in ascending order.
20. Write a Pandas program to change the name 'James' to 'Suresh' in name
column of the DataFrame.
21. Write a Pandas program to iterate over rows in a DataFrame.
22. Write a Pandas program to get list from DataFrame column headers.
23.rite a Pandas program to select rows from a given DataFrame based on
values in some columns.

Sample data:
Original DataFrame
col1 col2 col3
0147
1458
2369
3470
4581
Rows for colum1 value == 4
col1 col2 col3
1458
3470
24.

You might also like