Pandas Quiz
Check what you have learned in the Pandas tutorial with this quiz.
How the Quiz Works
There are ten questions. Pick an answer to see if it is right, with a short explanation. Assume import pandas as pd and a DataFrame called df.
| Questions | Topics |
|---|---|
| 1 to 3 | Series, DataFrames and files |
| 4 to 6 | Selecting, filtering and cleaning |
| 7 to 10 | Sorting, grouping and merging |
Questions
Exercise
1. What is a Pandas Series?
Exercise
2. Which function reads a CSV file into a DataFrame?
Exercise
3. What does df.shape return for a table with 200 rows and 6 columns?
Exercise
4. What is the main difference between loc and iloc?
Exercise
5. Which code keeps rows where qty is more than 5 AND city is "Karachi"?
Exercise
6. Which method replaces missing values with a value you choose?
Exercise
7. Which code removes repeated rows?
Exercise
8. Which code gives the average marks for each class?
Exercise
9. You have January and February tables with the same columns. How do you put them one under the other?
Exercise
10. In pd.merge(a, b, on="id"), what kind of join is used by default?
What Next?
Scored 8 or more? Try SciPy for statistics and science. Want more practice? Go back to selecting and filtering and grouping and try the examples with your own data.
