Pandas/Python Flashcards
What function is used to read a CSV file in pandas?
pd.read_csv()
True or False: The function pd.DataFrame() is used to create a DataFrame in pandas.
True
Fill in the blank: To display the first five rows of a DataFrame, you use the function ___.
df.head()
Which method is used to calculate the mean of a DataFrame column?
mean()
What is the syntax to filter a DataFrame ‘df’ for rows where the column ‘age’ is greater than 30?
df[df[‘age’] > 30]
What is the primary purpose of the groupby() function in data analysis?
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.
True or False: The groupby() function can only be used with numerical data.
False
Fill in the blank: The syntax for the groupby() function is ___.
dataframe.groupby(by=<column_name>)</column_name>
Which method can be used after groupby() to aggregate data?
The agg() method can be used after groupby() to aggregate data.
What does the ‘by’ parameter in the groupby() function specify?
The ‘by’ parameter specifies the column or columns to group the data by.
What is the code to convert all column names to lowercase?
df.columns = df.columns.str.lower()