Python Data Analysis
- 94Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is a Kaggle notebook?
An environment similar to a Jupyter notebook where code can be run alongside plain-text descriptions.
Or swipe the card
94 cards
What is a Kaggle notebook?
An environment similar to a Jupyter notebook where code can be run alongside plain-text descriptions.
What alias is commonly used when importing pandas?
pdWhat alias is commonly used when importing NumPy?
npWhich library is imported as
pltfor plotting?matplotlib.pyplotWhy is Seaborn useful in exploratory data analysis?
It provides helpful functions for creating exploratory plots and more advanced visualizations.
How can the default Matplotlib and Seaborn plotting style be changed to the ggplot style?
Use
plt.style.use('ggplot').How can pandas be configured to display up to 200 columns?
Use
pd.set_option('display.max_columns', 200).How can a CSV file be loaded into a pandas DataFrame?
Use
pd.read_csv()and assign the result to a variable such asdf.What does
df.shapereturn?The number of rows and columns in a DataFrame.
What does
df.head()display?The first five rows of a DataFrame by default.
How can the number of rows displayed by
head()be changed?Pass the desired number as an argument, such as
df.head(20).Why might
df.head()show dots between columns?Pandas hides some columns by default when the DataFrame is too wide.
How can all column names in a DataFrame be listed?
Use
df.columns.In pandas, what is a DataFrame column?
A pandas Series.
What does
df.dtypesshow?The data type assigned to each DataFrame column.
What does an
objectdata type commonly represent in a pandas column?String or text values.
What does
df.describe()provide?Summary statistics for numeric columns.
What did the count of 171 for roller-coaster height indicate?
There were 171 non-missing height values.
What was the mean roller-coaster height in the example?
101 feet.
Why should unwanted columns or rows be removed before extensive cleaning?
To avoid wasting time cleaning data that will not be used in the analysis.
Why might a dataset contain both text and numeric versions of a feature?
One column may include units or descriptive text, while another contains standardized numeric values.
How can selected DataFrame columns be retained using a list?
Place the list of desired column names inside double brackets, such as
df[columns].How can a column be removed with pandas
drop()?Use
df.drop(columns='column_name', axis=1)or provide a list of columns.What does
axis=1mean when usingdrop()?Operate on columns.
How can a selected subset of columns replace the original DataFrame?
Assign it back to the DataFrame variable, such as
df = df[columns].copy().Why is
.copy()useful after subsetting a DataFrame?It creates a new DataFrame rather than a reference to the original data.
What columns were retained in the cleaned roller-coaster subset?
Fields such as coaster name, location, manufacturer, year introduced, latitude, longitude, material type, opening date, speed, height, inversions, g-force, and status.
How did the dataset change after selecting the desired columns?
It was reduced to 13 columns while retaining 1,087 rows.
How can a column be converted to a datetime type?
Use
pd.to_datetime()on the column.Why should an opening-date column be converted from
objectto datetime?Because dates should be represented with a datetime type for correct interpretation and later analysis.
How can a column be converted to a numeric type?
Use
pd.to_numeric()on the column.How are DataFrame columns renamed with
rename()?Pass a dictionary mapping old names to new names through the
columnsargument.What naming improvements were made to the example columns?
Column names were made more consistent, with uppercase first letters and removal of unnecessary
_cleansuffixes.What does
df.isna()return?A Boolean DataFrame indicating whether each value is missing or null.
How can the number of missing values in each column be calculated?
Use
df.isna().sum().Which example columns contained missing values?
Status, latitude, longitude, and some g-force values.
What does
df.duplicated()identify?Rows that duplicate an earlier row or earlier matching row.
Why does
duplicated()normally ignore the first occurrence?It marks only the second and subsequent matching rows so they can be identified as redundant copies.
How can the duplicated rows themselves be displayed?
Use
.locwith the Boolean result ofduplicated(), such asdf.loc[df.duplicated()].How can duplication be checked using only selected columns?
Pass the relevant column names to the
subsetargument ofduplicated().How many repeated coaster names were found in the example?
97 duplicated rows.
Why might the same coaster name appear in multiple rows?
A coaster may have multiple records because it was introduced in different years or was taken offline and later reopened.
How can a specific coaster be investigated with
query()?Filter the DataFrame using a condition such as
df.query("Coaster Name== 'Crystal Beach Cyclone'").Which columns were used to define duplicate roller-coaster records for removal?
Coaster name, location, and opening date.
How can the inverse of a Boolean duplicate mask be selected?
Place the tilde operator,
~, before the Boolean mask.How can duplicate rows be removed while retaining the first matching record?
Filter with the inverse of
df.duplicated(subset=...)and assign the result back to the DataFrame.Why is
reset_index()useful after dropping rows?It creates a consecutive index for the remaining rows.
How can the old index be prevented from becoming a new column during reset?
Use
reset_index(drop=True).What was the final cleaned dataset size?
990 unique roller coasters and 13 feature columns.
What is univariate analysis?
Analysis of one feature or column at a time.
What does
value_counts()calculate?The number of occurrences of each unique value in a Series.
How does
value_counts()order its results by default?From the most frequent value to the least frequent value.
What did
value_counts()show for the year introduced?1999 was the most common year, with 46 roller coasters introduced.
How can the ten most common values be selected from
value_counts()?Use
.head(10)after callingvalue_counts().How can value counts be visualized as a bar plot?
Call
.plot(kind='bar')on the value-counts Series.How can a plot title and axis labels be added?
Use a title-setting method and axis-label methods such as
set_xlabel()andset_ylabel().What does a histogram show?
The counts of continuous values within defined bins.
Why can changing the number of histogram bins be useful?
It can make the shape of a distribution clearer or easier to interpret.
What did the roller-coaster speed histogram suggest?
Speeds around 40–50 miles per hour were common, with some unusually high speeds that could be investigated as potential outliers.
What is a kernel density estimate plot?
A smoothed, normalized representation of a variable's distribution.
How is a KDE plot created with pandas plotting?
Use a density or KDE plot option, such as
kind='kde'.What peaks appeared in the roller-coaster speed KDE plot?
Approximate peaks occurred around 35 and 50 miles per hour.
What does a scatter plot show?
The relationship between two numeric features using one point per observation.
How can a pandas scatter plot be created for speed and height?
Use
df.plot(kind='scatter', x='Speed', y='Height').Why might
plt.show()be added after a pandas plot?To display the plot cleanly without printing the underlying Matplotlib object representation.
How does Seaborn create a scatter plot?
Use
sns.scatterplot()withx,y, anddataarguments.How can the arguments of a plotting function be inspected in a notebook?
Use the notebook's documentation shortcut, such as Shift-Tab, inside the function call.
What does the
hueargument do in a Seaborn scatter plot?It colors points according to another variable.
What is a Seaborn pair plot?
A matrix of plots showing relationships between multiple features and distributions along the diagonal.
What type of plot appears between feature pairs in a pair plot by default?
A scatter plot.
What appears along the diagonal of a pair plot?
The distribution of each individual feature.
How can a pair plot encode a third variable?
Pass the variable to the
hueargument.What pattern did material type and year introduced reveal?
Steel coasters were uncommon in the earliest years and began appearing around the 1950s before becoming more popular.
What does a correlation measure?
The strength and direction of the relationship between numeric features.
What correlation was observed between roller-coaster speed and height?
Approximately 0.73.
What does a negative correlation indicate?
As one feature increases, the other tends to decrease.
Why might year introduced have weak correlations with other features?
It may not have a strong linear relationship with those features in the dataset.
Why should null values be removed before calculating correlations?
Correlation calculations should use paired numeric observations with available values.
How is a correlation matrix calculated in pandas?
Use the
corr()method on a numeric DataFrame.What does a Seaborn heat map of correlations show?
The strength and direction of correlations between features using color.
Why are the diagonal values of a correlation matrix equal to 1?
Each feature is perfectly correlated with itself.
What does adding annotations to a correlation heat map provide?
The numeric correlation values are displayed directly in the cells.
What question was asked in the final analysis?
Which locations have the fastest roller coasters, considering only locations with at least 10 coasters?
Why was the location value
otherexcluded from the final analysis?It was not a specific real location.
How can rows with a location other than
otherbe selected?Use a query condition such as
Location != 'Other'.Why is grouping by location useful for this question?
It allows speed statistics to be calculated separately for each location.
What does the
agg()method do in grouped analysis?It calculates one or more summary statistics for each group.
Which statistics were calculated for speed at each location?
The mean speed and the count of roller coasters.
How was the minimum-location-size condition applied?
Locations were filtered to those with a coaster count greater than or equal to 10.
Why were the grouped results sorted by mean speed?
To rank locations from lower to higher average coaster speed and identify the fastest locations.
What type of plot was used to display average coaster speed by location?
A horizontal bar plot.
Which location had the highest average coaster speed in the final result?
Busch Gardens.
Which location followed Busch Gardens in average coaster speed?
Cedar Point.
What general lesson does asking a concrete data question provide?
It guides the analyst toward the pandas operations needed to filter, group, aggregate, sort, and visualize the data.

Ask anything
We've read this whole study set, so questions about it get the best answers.