Pandas Flashcards
(78 cards)
What is a Pandas DataFrame?
A two-dimensional, size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns).
True or False: A Pandas Series is one-dimensional.
True
Fill in the blank: To create a DataFrame from a dictionary, you use the function __________.
pd.DataFrame()
What method is used to read a CSV file into a DataFrame?
pd.read_csv()
How do you access the first 5 rows of a DataFrame?
Using the method df.head()
What is the default index of a new DataFrame?
A RangeIndex starting from 0.
What is the purpose of the .describe() method in Pandas?
It generates descriptive statistics that summarize the central tendency, dispersion, and shape of a DataFrame’s distribution.
True or False: You can have multiple data types in a single DataFrame column.
False
Which function would you use to concatenate two DataFrames?
pd.concat()
What method would you use to drop a column from a DataFrame?
df.drop()
Fill in the blank: The method __________ is used to filter DataFrame rows based on a condition.
df.loc[]
What does the .info() method provide?
It provides a concise summary of a DataFrame, including the index dtype and columns, non-null values, and memory usage.
How can you check for missing values in a DataFrame?
Using the method df.isnull()
What is the purpose of the .groupby() method?
It is used to split the data into groups based on some criteria.
True or False: The index of a DataFrame can be modified after creation.
True
What is the difference between .loc[] and .iloc[]?
.loc[] is label-based indexing, while .iloc[] is position-based indexing.
Which function is used to create a Series from a list?
pd.Series()
Fill in the blank: To sort a DataFrame by a specific column, use the method __________.
df.sort_values()
What does the .apply() method do?
It applies a function along the axis of a DataFrame.
How would you reset the index of a DataFrame?
Using the method df.reset_index()
Which method would you use to merge two DataFrames on a key column?
pd.merge()
True or False: The shape attribute of a DataFrame returns the number of rows and columns.
True
What does the .pivot_table() method do?
It creates a spreadsheet-style pivot table as a DataFrame.
Fill in the blank: The __________ function is used to create a DataFrame from a NumPy array.
pd.DataFrame()