examples Flashcards

1
Q

“What does the .duplicated() method do in Pandas?”

A

“It checks for duplicate rows in a DataFrame and returns a boolean series.”

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

“How do you remove duplicate rows using Pandas?”

A

“Use .drop_duplicates() to remove duplicate rows from a DataFrame.”

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

“How can you rename columns in a DataFrame?”

A

“You can rename columns by using the .rename() method, passing a dictionary with old column names as keys and new names as values.”

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

“How do you change a column’s data type in Pandas?”

A

“Use the .astype() method to change the data type of a column in a DataFrame.”

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

“What does the .str.contains() method do in Pandas?”

A

“The .str.contains() method is used to check if a string or substring is present in each element of a column.”

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

“How can you replace substrings in a column using Pandas?”

A

“You can use the .str.replace() method to replace substrings in a column.”

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

“What is the difference between .apply(), .map(), and .applymap()?”

A

.apply() is used on Series or DataFrames for row/column-wise operations. .map() is used for element-wise operations in a Series. .applymap() is used for element-wise operations in a DataFrame.”

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

“What is the purpose of the groupby() method in Pandas?”

A

“The groupby() method is used to group data based on one or more columns and perform operations like aggregation on each group.”

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

“What are common aggregation functions used in Pandas?”

A

“Common aggregation functions include sum(), mean(), count(), min(), and max().”

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

“How do you create a pivot table in Pandas?”

A

“Use the .pivot_table() method to create a pivot table from a DataFrame by specifying the rows, columns, and values to aggregate.”

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

“What does the pd.crosstab() function do in Pandas?”

A

pd.crosstab() is used to compute a cross-tabulation of two or more factors, essentially creating a contingency table.”

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

“How do you concatenate DataFrames in Pandas?”

A

“You can concatenate DataFrames by using pd.concat() and specifying the axis along which to concatenate.”

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

“How do you merge two DataFrames on a specific column?”

A

“Use pd.merge() to merge DataFrames on a specific column, similar to SQL joins.”

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

“What is the difference between .join() and merge()?”

A

.join() is a method of the DataFrame that is used for joining by index, while merge() is used for merging by columns.”

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

“How do you convert a string column to a datetime object in Pandas?”

A

“Use pd.to_datetime() to convert a string column to a datetime object.”

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

“How do you extract the year from a datetime column?”

A

“Use .dt.year to extract the year from a datetime column.”

17
Q

“How do you extract the month and day from a datetime column?”

A

“Use .dt.month to extract the month and .dt.day to extract the day.”

18
Q

“What does .resample() do in Pandas?”

A

“The .resample() method is used for resampling time series data, allowing you to aggregate or downsample at different time frequencies.”

19
Q

“What is the purpose of rolling window operations like rolling().mean()?”

A

“Rolling window operations like rolling().mean() allow you to calculate a moving average or apply other functions over a sliding window of data.”

20
Q

“How do you set an index for a DataFrame?”

A

“Use the .set_index() method to set a column as the index of the DataFrame.”

21
Q

“How can you reset the index of a DataFrame?”

A

“Use the .reset_index() method to reset the index and move the index back to a column.”

22
Q

“What is the difference between rolling() and expanding()?”

A

rolling() computes a moving window function while expanding() computes cumulative statistics.”

23
Q

“How do you use the .query() method in Pandas?”

A

“The .query() method allows you to filter data in a DataFrame using a query string.”