Pandas/Python Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What function is used to read a CSV file in pandas?

A

pd.read_csv()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: The function pd.DataFrame() is used to create a DataFrame in pandas.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill in the blank: To display the first five rows of a DataFrame, you use the function ___.

A

df.head()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which method is used to calculate the mean of a DataFrame column?

A

mean()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax to filter a DataFrame ‘df’ for rows where the column ‘age’ is greater than 30?

A

df[df[‘age’] > 30]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the primary purpose of the groupby() function in data analysis?

A

The primary purpose of the groupby() function is to split the data into groups based on some criteria and then apply a function to each group.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False: The groupby() function can only be used with numerical data.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Fill in the blank: The syntax for the groupby() function is ___.

A

dataframe.groupby(by=<column_name>)</column_name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which method can be used after groupby() to aggregate data?

A

The agg() method can be used after groupby() to aggregate data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the ‘by’ parameter in the groupby() function specify?

A

The ‘by’ parameter specifies the column or columns to group the data by.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the code to convert all column names to lowercase?

A

df.columns = df.columns.str.lower()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly