This page contains review questions for teaching ITSE-1372 Int Comp Program Python at Austin Community College in Austin, TX.
The questions and the answers on this page are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.
The questions on this page are similar to the questions that you will find on the proctored tests for this course. Therefore, it is strongly recommended that you study the material until you thoroughly understand the material covered by these questions.
True or False: Pandas is a software library written for the Python programming language.
True or False: The Pandas library provides special scientific functions for the manipulation of numerical tables and time series.
True or False: Pandas provides three important data structures: Series, DataFrame, and BinaryTree.
True or False: A Series is a one-dimensional labeled array-like object. It is capable of holding any data type, e.g. integers, floats, strings, Python objects, and so on. It can be seen as a data structure with two arrays: one functioning as the index, i.e. the labels, and the other one contains the actual data.
True or False: Like the keys in a dictionary, the index values for a Series are required to be unique.
True or False: The default index for a Series is a numeric zero-based index.
True or False: If the default numeric index for a Series doesn't suit your needs, you can replace it with a set of Index values of your choosing, by providing a second argument to the Series constructor.
True or False: A Series object has its own built-in plot method.
True or False: The plot method for a Series object can create the following kinds of plots:
True or False: Like a spreadsheet or Excel sheet, a DataFrame object contains an ordered collection of columns. Each column consists of a unique data type, but different columns can have different types, e.g. the first column may consist of integers, while the second one consists of boolean values and so on.
True or False: A DataFrame object can be created by concatenating two or more Series objects.
True or False: True or False: A DataFrame object has its own built-in plot method.
True or False: The kinds of plots that can be created by the DataFrame plot method are the same as the kinds of plots that can be created by the Series plot method.
True or False: Pandas provides support for reading datasets in a variety of formats, including:
True or False: The method named pandas.read_csv can only read files having a .csv extension.
True or False: The DataFrame.head method will display the first five rows of a DataFrame object by default. The number of rows displayed can be changed by specifying the number of rows as an input argument.
True or False: By default, when loading a dataset by calling the pandas.read_csv method, the row index for the resulting DataFrame object is a zero-based numeric index. One of the columns of the DataFrame can be used as the row index by passing an argument named row_index to the method specifying the column to be used as the row index.
True or False: A DataFrame object can be called by calling the dataframe.transposition method on the object.
True or False: We can create a Pandas Series object with default numeric indices by calling the pandas.Series.constructor and passing a list of data values as an argument as shown below.
aSeries = pd.Series(['Tom','Dick','Harry'])
True or False: The following code shows how to create a Series object with specified values for both the index and the data.
ageIndex = ['Tom','Dick','Harry'] ageValues = [39,42,65] ageSeries = pd.Series(ageIndex,ageValues)
True or False: The following code shows how to create a Series object with specified values for both the index and the data.
ageIndex = ['Tom','Dick','Harry','Tom'] ageValues = [39,42,65,15] ageSeries = pd.Series(index=ageIndex,data=ageValues,)
True or False: The following code shows how to create a Series object.
aDict = {'Tom':32,'Dick':65,'Harry':21} ageSeries = pd.Series(aDict)
True or False: Series objects can be added to one another.
True or False: The Series.iloc method can be used to access data by label(s) or a boolean array, whereas the Series.loc method provides integer-location based or boolean indexing for selection by position.
True or False: You can perform scalar operations, such as multiplying a Series object by a constant or adding a constant to a Series object using code such as the following:
ageIndex = ['Tom','Dick','Harry','Tom'] ageValues = [10,20,30,40] ageSeries = pd.Series(index=ageIndex,data=ageValues,) ageSeries = ageSeries + 2 ageSeries = ageSeries * 2
The operation is applied to each data element in the object.
True or False: You can apply mathematical functions to a Series object using code such as the following, causing the function to applied to each data element in the object.
ageIndex = ['Tom','Dick','Harry','Tom'] ageValues = [10,20,30,40] ageSeries = pd.Series(index=ageIndex,data=ageValues,) ageSeries = np.sqrt(ageSeries)
True or False: Once you have a Pandas Series object, there are many methods that you can call on the object such as abs, add, apply, and sister.
True or False: The Series.apply method must be used to call a specified function on a Pandas Series object,
True or False: The Series.apply method can be used with lambda functions.
True or False: A Pandas Series object, as well as a Pandas DataFrame object can have data missing from one or more cells. When this happens, that cell is flagged with NaN,
True or False: The methods Series.ismissing and Series.notmissing can be used to test for missing data in a Pandas Series object. Similar methods can be used to test for missing data in a Pandas DataFrame object.
True or False: The Series.dropna method can be used to remove missing values from a Pandas Series object. The method returns a Pandas Series object containing only non-null data. A similar method can be used to remove missing values from a Pandas DataFrame object.
True or False: In some cases, the Series.fillnan method can be used to repair a Pandas Series object that has missing data.
True or False: The following code will load a dataset file named MyData.pdq into a Pandas DataFrame object provided that the format of the data in the file meets the requirements of the pandas.read_csv method.
TestData = pd.read_csv('MyData.pdq')
True or False: The general syntax for accessing a subset of a Pandas DataFrame object is:
dataFrameObject.loc[startrow:endrow, startcolumn:endcolumn]
True or False: The following code writes the contents of the Pandas DataFrame object named TestData12 into an output CSV file named csvOutput.csv.
TestData12.to_csvFile('csvOutput.csv')
False
Explanation
The code should read:
TestData12.to_csv('csvOutput.csv')
The method name was not spelled correctly.
True
True
False.
Explanation
In some cases, the Series.fillna method can be used to repair a Pandas Series object that has missing data. The spelling of the method name is incorrect in the question.
True
False
Explanation
The methods Series.isnull and Series.notnull can be used to test for missing data in a Pandas Series object. Similar methods can be used to test for missing data in a Pandas DataFrame object.
True
True
False
Explanation
The Series.apply method provides an alternative way to call a specified function on the object. That is not the only way to call a function on the object.
False
Explanation
A Pandas Series object does not have a method named sister.
True
True
False.
Explanation
The Series.loc method can be used to access data by label(s) or a boolean array, whereas the Series.iloc method provides integer-location based or boolean indexing for selection by position.
Note that the names of the methods were reversed in the question.
True
True
Explanation
You can create a Series from a dictionary, in which case we get a Series with the indices sorted.
True
Explanation
The data and index arguments can be treated as positional arguments and passed in the order specified by the constructor documentation, or they can be treated as named arguments and entered in a different order.
False
Explanation
The code should read as follows. The ageIndex and ageValues arguments were reversed in the code shown earlier.
ageIndex = ['Tom','Dick','Harry'] ageValues = [39,42,65] ageSeries = pd.Series(ageValues,ageIndex)
True
False
Explanation
A DataFrame object can be called by calling the dataframe.transpose method on the object.
False
Explanation
True or False: By default, when loading a dataset by calling the pandas.read_csv method, the row index for the resulting DataFrame object is a zero-based numeric index. One of the columns of the DataFrame can be used as the row index by passing an argument named index_col to the method specifying the column to be used as the row index.
True
False
Explanation
Insofar as Pandas is concerned, the file extension doesn't matter. A text file containing tab-separated values could have an extension of .pdq, .txt, .csv, or no extension at all and it would still be treated the same by the pandas.read_csv() method. It is the internal structure and not the file extension that is important in the treatment of the file by the pandas.read_csv() method.
False
Explanation
Pandas provides support for reading datasets in a variety of formats, including:
Pandas does not provide a method named pandas.read_jpeg.
False
Explanation
The DataFrame plot method adds the following two kinds of plots that are not included in the kinds of plots that can be created by the Series plot method.
True
Explanation
True
Explanation
True
False
Explanation
A Series object doesn't have the ability to produce a 'cake' plot. See https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.plot.html?highlight=series%20plot#pandas.Series.plot
True
Explanation
True
True
False
Explanation
A series can be thought of as a one-dimensional vertical (column) array with an index similar to a Python dictionary. However, unlike the keys in a dictionary, the index values for a Series are not required to be unique.
True
False
Explanation
Pandas does not provide a BinaryTree data structure.
False
Explanation
The Pandas library provides special data structures and operations for the manipulation of numerical tables and time series.
True
Explanation
Author: Prof. Richard G. Baldwin
Affiliation: Professor of Computer Information Technology at Austin Community College in Austin, TX.
File: PandasReview.htm
Revised: 09/03/18
Copyright 2018 Richard G. Baldwin