Quiz: Python Data Import and Analysis
Main.PythonQuiz12 History
Hide minor edits - Show changes to output
Changed line 87 from:
->'''C.''' print(data[-6:])
to:
->'''C.''' print(data[-6])
Added lines 1-126:
(: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 [[Main/PythonDataAnalysis|reviewed here]]? Select two options.
->'''A.''' CSV reader
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%red%Incorrect.%% The ''csv'' package does have a ''reader'' function, but it is not [[Main/PythonDataAnalysis|reviewed here]].
(:divend:)
->'''B.''' Numpy
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%blue%Correct.%% Numpy has ''loadtxt'' as a function to import data.
(:divend:)
->'''C.''' Scipy
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%Incorrect.%% Scipy (or Scientific Python) is a common package for analyzing data, but is not commonly known for data import functions.
(:divend:)
->'''D.''' Pandas
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
-->%blue%Correct.%% Pandas can import many types of files into ''DataFrames'' that are tables of the imported data.
(:divend:)
->'''E.''' Excel
-->(:toggle hide q1e button show="Select":)
(:div id=q1e:)
-->%red%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?
->'''A.''' print(data[1:5])
-->(:toggle hide q2a button show="Select":)
(:div id=q2a:)
-->%red%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:)
->'''B.''' print(data[0:5])
-->(:toggle hide q2b button show="Select":)
(:div id=q2b:)
-->%blue%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:)
->'''C.''' print(data[0:6])
-->(:toggle hide q2c button show="Select":)
(:div id=q2c:)
-->%red%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?
->'''A.''' print(data[-5:])
-->(:toggle hide q3a button show="Select":)
(:div id=q3a:)
-->%blue%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:)
->'''B.''' print(data[-5])
-->(:toggle hide q3b button show="Select":)
(:div id=q3b:)
-->%red%Incorrect.%% This command only prints the 5th to last row of ''data''.
(:divend:)
->'''C.''' print(data[-6:])
-->(:toggle hide q3c button show="Select":)
(:div id=q3c:)
-->%red%Incorrect.%% This command only prints the 6th to last row of ''data''.
(:divend:)
->'''D.''' print(data[-4:])
-->(:toggle hide q3d button show="Select":)
(:div id=q3d:)
-->%red%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 [[https://apmonitor.com/pds/index.php/Main/GatherData|Data Science: Gather Data]] for a list of export functions.
->'''A.''' data.to_csv('result.csv') # to export to a CSV file
-->(:toggle hide q4a button show="Select":)
(:div id=q4a:)
-->%blue%Correct.%%
(:divend:)
->'''B.''' data.to_excel('result.xlsx') # to export to an Excel file
-->(:toggle hide q4b button show="Select":)
(:div id=q4b:)
-->%blue%Correct.%%
(:divend:)
->'''C.''' data.to_clipboard()
-->(:toggle hide q4c button show="Select":)
(:div id=q4c:)
-->%blue%Correct.%%
(:divend:)
----
(: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 [[Main/PythonDataAnalysis|reviewed here]]? Select two options.
->'''A.''' CSV reader
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%red%Incorrect.%% The ''csv'' package does have a ''reader'' function, but it is not [[Main/PythonDataAnalysis|reviewed here]].
(:divend:)
->'''B.''' Numpy
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%blue%Correct.%% Numpy has ''loadtxt'' as a function to import data.
(:divend:)
->'''C.''' Scipy
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%Incorrect.%% Scipy (or Scientific Python) is a common package for analyzing data, but is not commonly known for data import functions.
(:divend:)
->'''D.''' Pandas
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
-->%blue%Correct.%% Pandas can import many types of files into ''DataFrames'' that are tables of the imported data.
(:divend:)
->'''E.''' Excel
-->(:toggle hide q1e button show="Select":)
(:div id=q1e:)
-->%red%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?
->'''A.''' print(data[1:5])
-->(:toggle hide q2a button show="Select":)
(:div id=q2a:)
-->%red%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:)
->'''B.''' print(data[0:5])
-->(:toggle hide q2b button show="Select":)
(:div id=q2b:)
-->%blue%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:)
->'''C.''' print(data[0:6])
-->(:toggle hide q2c button show="Select":)
(:div id=q2c:)
-->%red%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?
->'''A.''' print(data[-5:])
-->(:toggle hide q3a button show="Select":)
(:div id=q3a:)
-->%blue%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:)
->'''B.''' print(data[-5])
-->(:toggle hide q3b button show="Select":)
(:div id=q3b:)
-->%red%Incorrect.%% This command only prints the 5th to last row of ''data''.
(:divend:)
->'''C.''' print(data[-6:])
-->(:toggle hide q3c button show="Select":)
(:div id=q3c:)
-->%red%Incorrect.%% This command only prints the 6th to last row of ''data''.
(:divend:)
->'''D.''' print(data[-4:])
-->(:toggle hide q3d button show="Select":)
(:div id=q3d:)
-->%red%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 [[https://apmonitor.com/pds/index.php/Main/GatherData|Data Science: Gather Data]] for a list of export functions.
->'''A.''' data.to_csv('result.csv') # to export to a CSV file
-->(:toggle hide q4a button show="Select":)
(:div id=q4a:)
-->%blue%Correct.%%
(:divend:)
->'''B.''' data.to_excel('result.xlsx') # to export to an Excel file
-->(:toggle hide q4b button show="Select":)
(:div id=q4b:)
-->%blue%Correct.%%
(:divend:)
->'''C.''' data.to_clipboard()
-->(:toggle hide q4c button show="Select":)
(:div id=q4c:)
-->%blue%Correct.%%
(:divend:)
----