Exam 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the result of the following boolean indexing operation? names = np.array(['Bob', 'Joe', 'Will', 'Bob', 'Will', 'Joe',]) data = np.array([[1,2,3,4], [5,6,7,8], [13,14,15,16], [17,18,19,20], [21,22,23,24]]) mask = (names == 'Bob') | (names == 'Will') data[mask]

array([[1,2,3,4], [9,10,11,12], [13,14,15,16], [17,18,19,20]])

When a hashing algorithm maps items to the same index what technique is used to resolve the conflict?

chaining

Which of the following statements is false? a. DataFrames can have custom row and columns indices, and offer additional operations and capabilities that make them more convenient for many data-science oriented tasks. b. DataFrames support missing data. c. The series representing each column may contain different element types. d. All of the above statements are true.

d. All of the above statements are true.

What is the result of the following code? obj = pd.Series(range(3), index=['a', 'b', 'c']) index = obj.index index[1] = 'd'

Error Note: indexes are immutable. Cannot change subscripted elements in index. Use reindex method

True or False: What is the output of the following code. pop = {'Nevada': {2001: 1}, 'Ohio': {2000: 0, 2001: 1}} frame3 = pd.DataFrame(pop) frame3 'Ohio' in fram3.index

False

True or False?: The following code generates the following output obj2 = pd.Series(["d", "b", "a", "c"], [4, 7, -5, 3]) obj2 d 4 b 7 a -5 c 3

False

What will the following code display? stuff = {1: 'aaa', 2: 'bbb', 3: 'ccc'} for key, value in stuff: print(key, value)

None of these

data = pd.DataFrame(np.arange(6).reshape((3,2)), index=['a', 'b', 'c'], columns=['a', 'b']) data[(data['b'] >= 2)] = 0

None of these output is: a b a 0 1 b 0 0 c 0 0

Object oriented programming and data structures have a different focus when it comes to organizing data. Describe the difference in focus.

OOP is focused on bundling different types of data. Data structures focus on organizing large amounts of data of the same type.

The following operation is valid if arr is a numpy array having no zeros. 1/arr

True

Which of the following statements is false? a. DataFrames have a describe method that calculates basic descriptive statistics for the data and returns them as a two-dimensional array. b. In a DataFrame, the statistics are calculated by column. c. Method describe nicely demonstrates the power of array-oriented programming with a functional-style call-Pandas handles internally all the details of calculating these statistics for each column. d. You can control the precision of floating-point values and other default settings with pandas' set_option function.

a. DataFrames have a describe method that calculates basic descriptive statistics for the data and returns them as a two-dimensional array.

Assuming the following grades DataFrame: Wally Eva Sam Katie Bob Test1 87 100 94 100 83 test2 96 87 77 81 65 test3 70 90 90 82 85 which of the following statements is false a. One benefit of pandas is that you can quickly and conveniently look at your data in many different ways, including selecting portions of the data b. The following expression selects the 'Eva' column and returns it as a Series: grades['Eva'] c. If a DataFrame's column-name strings are valid Python identifiers, you can use them as attributes. The following code selects the 'Sam' column using the Sam attribute: grades.Sam d. All of the above statements are true

d. All of the above statements are true

Which of the following statements is false? a. With DataFrames you can specify custom indexes with the index keyword argument when we create a DataFrame, as in: grades_dict = {'Wally': [87, 96, 70], 'Eva': [100, 87, 90], 'Sam': [94, 77, 90], 'Katie': [100, 81, 82], 'Bob': [83, 65, 85]} import pandas as pd pd.DataFrame(grades_dict, index=['Test1', 'Test2', 'Test3]) b. The following code uses the index attribute to change the DataFrame's indexes from sequential integers to labels: grades.index = ['Test1', 'Test2', 'Test3'] c. When specifying the indexes, you must provide a one-dimensional collection that has the same number of elements as there are rows in the DataFrame; otherwise, a ValueError occurs. d. All of the above statements are true

d. All of the above statements are true

df = pd.DataFrame([[1,1], [2,2,], [3,3]], index=['a','b','c'], columns=['one', 'two'])

df.sum() : one 6 two 6 df.sum(axis='columns'): a 2 b 4 c 6 df.mean(axis='columns'): a 1.0 b 2.0 c 3.0 df.idmax(): one c two c df.cumsum(): one two a 1 1 b 3 3 c 6 6

What data structure is used to model data with FIFO behavior?

queue

The following class implements the basic operations of what data structure? class ds: _L = [] def method1(self, item): self._L.append(item def method2(self): return self._L.pop()

stack


संबंधित स्टडी सेट्स

ECON 2110 Exam 2 - Clemson University - Michael Zhao

View Set

Basics of Information Security PT 1

View Set

Cybersecurity Principles Final Practice Exam

View Set

PrepU Videbeck Ch 18 Personality Disorders

View Set

Medialab questions that I got wrong

View Set

AP Psych 5 Steps to a 5 Chapter 1 Schools of Thought

View Set