Python Functions, Data Structures, and Pandas Data Analysis

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/101

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:49 AM on 5/5/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

102 Terms

1
New cards

A generator function uses yield to yield a potentially infinite sequence of values rather than using return once.

True

2
New cards

s = "orange is the new blue"; s.replace("orange", "blue")

"blue is the new blue"

3
New cards

Any function in Python with no return value is actually returning what?

None

4
New cards

L = [2, 3, 5, 7, 11]; L[0:3]

[2, 3, 5]

5
New cards

s = "orange is the new blue"; s.partition(" ")

("orange", " ", "is the new blue")

6
New cards

Compared to lists, the main distinguishing feature of tuples is that they are what?

immutable

7
New cards

In Python every statement must end with a semicolon (;).

False

8
New cards

Strings in Python are created with single or double quotes.

True

9
New cards

a = [1, 2, 3]; b = [5, 7, 9]; a == b

False

10
New cards

result = (4 < 1); result

False

11
New cards

Python arithmetic has limited precision.

False

12
New cards

What statement is used for testing truth in and third-party modules?

import

13
New cards

Loops in Python are a way to repeatedly execute some code statement.

True

14
New cards

System refers to what?

the documentation of the program

15
New cards

numbers = ["one", "two", "three"]; numbers[0] = "four"; numbers

["four", "two", "three"]

16
New cards

L = [0, 1, 2, 7, 11]; L[-1]

11

17
New cards

To check if x is between 15 and 30 in Python, use what expression?

x > 15 and x < 30

18
New cards

In Python, indented code blocks are always preceded by a colon on the previous line.

True

19
New cards

Which one of the following is a generator expression?

(val for val in line)

20
New cards

def add(x, y): z = x + y; return z. How many arguments does add take?

2

21
New cards

L = [2, 5, 1, 0, 3, 4]; L.sort(); L

[0, 1, 2, 3, 4, 5]

22
New cards

a = [1, 2, 3]; b = [1, 2, 3]; a == b

True

23
New cards

if x is 15 < x < 30, then what condition should be used?

x > 15 and x < 30

24
New cards

The Index object follows many conventions used by Python built-in set data structure.

True

25
New cards

indA = pd.Index([1, 3, 5, 7, 9]); indB = pd.Index([2, 3, 5, 7, 11]); indA & indB / intersection

Int64Index([3, 5, 7], dtype="int64")

26
New cards

indA = pd.Index([1, 3, 5, 7, 9]); indB = pd.Index([2, 3, 5, 7, 11]); indA | indB / union

Int64Index([1, 2, 3, 5, 7, 9, 11], dtype="int64")

27
New cards

A Pandas Series is a one-dimensional array of indexed data.

True

28
New cards

A DataFrame is an analog of a two-dimensional array with flexible row indices and flexible column names.

True

29
New cards

Unlike a dictionary, the Series supports array-style operations such as slicing.

True

30
New cards

The index of a Series object should be an integer.

False

31
New cards

Like a dictionary, the Series object provides a mapping from a collection of keys to a collection of values.

True

32
New cards

For data = pd.Series([0.25, 0.5, 0.75, 1.0], index=["a", "b", "c", "d"]), data["a"]

0.25

33
New cards

For data = pd.Series([0.25, 0.5, 0.75, 1.0], index=["a", "b", "c", "d"]), data[1]

0.50

34
New cards

For data = pd.Series(["a", "b", "c"], index=[1, 3, 5]), data[1]

"a"

35
New cards

For data = pd.Series(["a", "b", "c"], index=[1, 3, 5]), data.iloc[1]

"b"

36
New cards

To get states with more than 20 million inhabitants from a DataFrame with pop column, use what?

data["pop"] > 20000000

37
New cards

What are the two special sentinels that can indicate a missing value?

None and NaN

38
New cards

Which Pandas function returns a copy of the data with missing values filled or imputed?

fillna()

39
New cards

Which Pandas function returns a filtered version of the data by dropping missing values?

dropna()

40
New cards

What function can fill each NA value using the previous value in the DataFrame?

data.fillna(method="ffill")

41
New cards

To fill NA entries in a DataFrame data with a single value, such as zero, use what?

data.fillna(0)

42
New cards

Real-world data is rarely clean and homogeneous.

True

43
New cards

What method converts a multiply indexed Series into a conventionally indexed DataFrame?

unstack()

44
New cards

A multi-indexed Series can be converted to a DataFrame.

True

45
New cards

Pandas allows MultiIndex for columns.

True

46
New cards

A MultiIndex can be used to represent data of more than two dimensions in a Series.

True

47
New cards

A multi-index can represent two-dimensional data within a one-dimensional Series.

True

48
New cards

Concatenating two DataFrames can result in duplicate index values.

True

49
New cards

Pandas includes functions and methods that make combining and joining data from multiple sources fast and straightforward.

True

50
New cards

When concatenating two DataFrames, to restrict the result to common columns, use which option?

join="inner"

51
New cards

ser1 = pd.Series(["A", "B", "C"], index=[1, 2, 3]); ser2 = pd.Series(["D", "E", "F"], index=[1, 2, 3]); pd.concat([ser1, ser2])

1 A; 2 B; 3 C; 1 D; 2 E; 3 F

52
New cards

Pandas only supports inner joins.

False

53
New cards

One essential feature of Pandas is high-performance, in-memory join and merge operations.

True

54
New cards

By default, pd.merge() uses common columns across the DataFrames to join.

True

55
New cards

By default, pd.merge() discards the index.

True

56
New cards

Using Pandas, we can manipulate data using relational algebra like relational databases.

True

57
New cards

The pd.merge() function implements one-to-one, many-to-one, and many-to-many joins.

True

58
New cards

A handy Pandas function to calculate descriptive statistics for all columns in a DataFrame is what?

describe()

59
New cards

To aggregate data in Pandas, use what function?

groupby

60
New cards

An essential piece of analysis of large data is efficient summarization by computing aggregations like sum(), mean(), median(), min(), and max().

True

61
New cards

The three steps in a groupby operation are what?

split, apply, combine

62
New cards

It is possible to define custom aggregations in Pandas.

True

63
New cards

To convert a column of string values to multiple columns of numerical values, use which method?

get_dummies() method

64
New cards

Slicing is not allowed in Pandas vectorized string operations.

False

65
New cards

Regular expressions are supported in Pandas vectorized string operations.

True

66
New cards

One advantage of Pandas vectorized strings compared to built-in string methods is what?

graciously handling missing values

67
New cards

Nearly all Python built-in string methods are mirrored by a Pandas vectorized string method.

True

68
New cards

Time deltas reference what?

an exact length of time

69
New cards

To compute aggregate values of time Series over time, use which function?

rolling()

70
New cards

Time stamps reference what?

particular moments in time

71
New cards

The difference between time intervals and periods is what?

Periods usually reference a special case of time intervals in which each interval is of uniform length and does not overlap.

72
New cards

The difference between shift() and tshift() is what?

shift() shifts the data, while tshift() shifts the index

73
New cards

The difference between two Timestamp values is what type?

Timedelta

74
New cards

To create a Timestamp object from the string "May 18 2019", use what?

pd.to_datetime("May 18 2019")

75
New cards

When resampling a time series, the primary difference between resample() and asfreq() is what?

resample() is fundamentally a data aggregation, while asfreq() is fundamentally a data selection

76
New cards

One of the most common problems with REST is what?

overfetching data from the server

77
New cards

Which attribute extracts the response content as a string?

text

78
New cards

JSON encodes complex data by combining what?

lists, dictionaries, strings, and numbers

79
New cards

When a request is sent, whether it was successful is inside which property?

status_code

80
New cards

To convert a Python object to a JSON string, use what?

json.dumps(object)

81
New cards

REST API allows sophisticated queries against the data in the server.

False

82
New cards

Which status code indicates the request was successful and data was returned?

200

83
New cards

Which status code indicates the resource was not found?

404

84
New cards

Which requests function obtains data from a server?

GET

85
New cards

API stands for what?

Application Programming Interface

86
New cards

GraphQL allows for writing a data schema that defines how a client can access the data.

True

87
New cards

Which HTTP method is used to retrieve a specified resource from the Web?

GET

88
New cards

XQUERY and XPATH are incompatible.

False

89
New cards

XQuery is built on XPath expressions.

True

90
New cards

The structure of an XML document is specified with nested attributes.

False

91
New cards

XML stands for what?

Extensible Markup Language

92
New cards

In an XML document, the top-level element is called what?

root

93
New cards

XQuery for XML is like SQL for databases.

True

94
New cards

The code "for $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return $x/title" is an example of what?

an XQUERY query

95
New cards

XML organizes data in what kind of structure?

hierarchical tree-like structure

96
New cards

Which is not designed to process XML documents: XQUERY, ElementTree, SQL, or XPATH?

SQL

97
New cards

HTML tag classes and ids are used for what?

used by CSS to determine which HTML elements to apply certain styles to

98
New cards

When two tags are nested within the same parent tag, they are an example of what relationship?

sibling

99
New cards

Which Python package is used to parse an HTML document?

BeautifulSoup

100
New cards

HTML tags can be nested within other tags.

True