Quiz: Python Data Import and Analysis
Main.PythonQuiz12 History
Hide minor edits - Show changes to markup
(:title Quiz: Python Data Import and Analysis:) (:keywords quiz, test, Python, pandas, numpy, loadtxt, csv_read, introduction, course:) (:description Learning assessment on Python data analysis and import.:)
1. What are the two common Python packages for importing and analyzing data that are reviewed here? Select two options.
(:div id=q1a:)
- Incorrect. The csv package does have a reader function, but it is not reviewed here.
(:divend:)
(:div id=q1b:)
- Correct. Numpy has loadtxt as a function to import data.
(:divend:)
(:div id=q1c:)
- Incorrect. Scipy (or Scientific Python) is a common package for analyzing data, but is not commonly known for data import functions.
(:divend:)
(:div id=q1d:)
- Correct. Pandas can import many types of files into DataFrames that are tables of the imported data.
(:divend:)
(:div id=q1e:)
- Incorrect. Excel can import data but it is not a Python function.
(:divend:)
2. Slicing a data set in Python means that you take a part of the larger data set. In order to print the first 5 rows of a pandas data set called data, what command would you use?
(:div id=q2a:)
- Incorrect. This command prints rows 1,2,3,4 (4 total rows). Python starts with a zero index. The last number (5) is not included.
(:divend:)
(:div id=q2b:)
- Correct. This command prints rows 0,1,2,3,4 (5 total rows). Python starts with a zero index. The last number (5) is not included.
(:divend:)
(:div id=q2c:)
- Incorrect. This command prints rows 0,1,2,3,4,5 (6 total rows).
(:divend:)
3. What command would you use to print the last 5 rows of data as a pandas object?
(:div id=q3a:)
- Correct. data[-1] is the last row, data[-2] is the second to last row, and so on. The missing number after the : symbol indicates the end.
(:divend:)
(:div id=q3b:)
- Incorrect. This command only prints the 5th to last row of data.
(:divend:)
(:div id=q3c:)
- Incorrect. This command only prints the 6th to last row of data.
(:divend:)
(:div id=q3d:)
- Incorrect. data[-1] is the last row, data[-2] is the second to last row, and so on. The missing number after the : symbol indicates the end. This command prints the 4th to last to the last row and misses the 5th to last row.
(:divend:)
4. Suppose that you want to export the pandas object "data" from Python. Which commands are valid? Select all that are correct. See Data Science: Gather Data for a list of export functions.
(:div id=q4a:)
- Correct.
(:divend:)
(:div id=q4b:)
- Correct.
(:divend:)
(:div id=q4c:)
- Correct.
(:divend:)