Python Data Analysis
- 71Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is a Kaggle notebook, and how is it similar to a Jupyter notebook?
71 questions
- 1
What is a Kaggle notebook, and how is it similar to a Jupyter notebook?
Model answer
A Kaggle notebook is an environment where users can run code and write plain-text descriptions. It is similar to a Jupyter notebook because both combine executable code cells with explanatory text.
Explanation
The content describes notebooks as environments for combining code execution and written descriptions.
- 2
Which Python packages are imported for data analysis and visualization in the tutorial, and what aliases are used for them?
Model answer
Pandas is imported as
pd, NumPy asnp, Matplotlib PyLab asplot, and Seaborn assns.Explanation
These packages provide data-frame operations, numerical tools, plotting, and exploratory visualizations.
- 3
Why is Seaborn useful during exploratory data analysis?
Model answer
Seaborn provides helpful functions for creating exploratory plots and more advanced statistical visualizations.
Explanation
The tutorial uses Seaborn for scatter plots, pair plots, and heat maps.
- 4
What does
plot.style.use('ggplot')accomplish?Model answer
It applies the
ggplotstyle sheet to Matplotlib and Seaborn plots.Explanation
The style sheet changes the appearance of plots to a preferred visual style.
- 5
How can Pandas be configured to display more columns in a data frame?
Model answer
Use
pd.set_optionto setdisplay.max_columnsto a sufficiently large number, such as 200.Explanation
This prevents Pandas from replacing columns with ellipses when displaying wide data frames.
- 6
How can a data set be added to a Kaggle notebook?
Model answer
A user can select an existing data set through “Add Data” or upload a personal data set.
Explanation
Kaggle provides both existing data sets and upload functionality.
- 7
How can a local CSV file be loaded into a Pandas data frame?
Model answer
Use
pd.read_csvwith the path to the CSV file, and assign the result to a variable such asdf.Explanation
The tutorial loads the coaster data with
pd.read_csvand names the resulting data framedf. - 8
What kind of information is contained in the roller-coaster data set?
Model answer
It contains information about more than 1,000 roller coasters, including speed, construction material, height, and other features.
Explanation
The tutorial uses this data set to demonstrate exploratory data analysis.
- 9
What does the
shapeattribute of a Pandas data frame show?Model answer
It shows the number of rows and columns in the data frame.
Explanation
For the initially loaded data set,
df.shapereports 1,087 rows and 56 columns. - 10
What does the
headmethod display, and how can its output be changed?Model answer
It displays the first five rows by default, but a number can be supplied to display a different number of rows, such as the first 20.
Explanation
Using
df.head(20)changes the default number of displayed rows. - 11
Why might a data frame display dots between groups of columns?
Model answer
Pandas hides some columns by default when the data frame is too wide, replacing them with dots.
Explanation
Changing the maximum displayed-column setting allows all columns to be shown.
- 12
How can all column names in a data frame be viewed?
Model answer
Use the
df.columnsattribute.Explanation
This returns the complete collection of column names.
- 13
In Pandas, what is a column in a data frame considered to be?
Model answer
Each column in a data frame is a Pandas Series, and every Series has a data type.
Explanation
This relationship explains why the data type of each column can be inspected individually.
- 14
What does
df.dtypesreveal?Model answer
It shows the data type assigned by Pandas to each column.
Explanation
The tutorial finds object columns for strings and numeric types such as floats and integers.
- 15
What does an
objectdata type usually represent in this data set?Model answer
It usually represents a string-valued column.
Explanation
Many descriptive columns, such as names or locations, are stored as object columns.
- 16
What information does
df.describe()provide?Model answer
It provides summary statistics for numeric columns, including count, mean, and other distributional measures.
Explanation
These statistics help establish an initial understanding of the numeric data.
- 17
What did the descriptive statistics show about roller-coaster height?
Model answer
Height had 171 available values and an average of about 101 feet.
Explanation
The count indicates that some height values were missing.
- 18
Why should unwanted columns or rows be removed before cleaning the remaining data?
Model answer
Removing them first prevents time from being spent cleaning information that will not be used in the analysis.
Explanation
Data preparation should focus only on the portion of the data set that will be analyzed.
- 19
Why might a data set contain both text and numeric versions of a feature such as speed?
Model answer
The text version may include units or other words, while the numeric version removes the text and standardizes the values for analysis.
Explanation
The numeric speed column stores values consistently in miles per hour.
- 20
How can specific columns be selected from a Pandas data frame?
Model answer
Pass a list of desired column names inside double brackets, such as
df[[column1, column2]].Explanation
Selecting a list creates a data frame containing only the chosen columns.
- 21
What is another way to remove columns from a data frame?
Model answer
Use the
dropmethod and provide the column name or a list of column names.Explanation
For example, a column can be removed with
df.drop(columns, axis=1). - 22
Why is
axis=1used when dropping a column?Model answer
It tells Pandas to operate on columns rather than rows.
Explanation
In this context,
axis=1distinguishes column removal from row removal. - 23
Why should a subsetted data frame sometimes be followed by
.copy()?Model answer
It ensures that Pandas treats the subset as a new, independent data frame rather than merely a reference to the original.
Explanation
This makes later data manipulation safer and avoids reference-related problems.
- 24
What was the result of reducing the original data set to the selected columns?
Model answer
The data set retained 1,087 rows but was reduced from 56 columns to 13 columns.
Explanation
The selected columns contained the features intended for further analysis.
- 25
How can an object column containing dates be converted to a date-time type?
Model answer
Apply
pd.to_datetimeto the column.Explanation
Converting the opening-date column changed its type to
datetime64. - 26
How can a column be converted to a numeric type?
Model answer
Apply
pd.to_numericto the column.Explanation
Pandas attempts to convert values such as numeric strings into a numeric data type.
- 27
How are column names renamed in Pandas?
Model answer
Use
df.rename(columns=...)with a dictionary mapping each old name to its new name.Explanation
The tutorial uses this method to standardize capitalization and remove unwanted naming details.
- 28
Why is it useful to avoid spaces in column names?
Model answer
Column names without spaces are generally easier to reference in code.
Explanation
The tutorial notes that the selected data already avoids spaces in its column names.
- 29
How can the number of missing values in each column be calculated?
Model answer
Apply
isna()to the data frame and then usesum()by column.Explanation
This produces a column-by-column count of null values instead of displaying every individual Boolean result.
- 30
Which types of features were identified as having missing values in the data set?
Model answer
Status, latitude, longitude, and some G-force values contained missing entries.
Explanation
Missing-value inspection identifies where later cleaning or interpretation may be necessary.
- 31
What does
duplicated()return by default?Model answer
It identifies the second and subsequent occurrences of duplicate rows while ignoring the first occurrence.
Explanation
The result is a Boolean series indicating which rows are duplicates.
- 32
How can the actual duplicated rows be displayed?
Model answer
Use the Boolean result from
duplicated()with.locto select the duplicate rows.Explanation
Boolean indexing isolates the rows marked as duplicates.
- 33
How can duplicate values be checked using only selected columns?
Model answer
Pass the relevant column names to the
subsetparameter ofduplicated().Explanation
This allows duplication to be evaluated using fields such as coaster name alone.
- 34
Why might two rows have the same roller-coaster name without being identical records?
Model answer
The same coaster name may occur at different locations, on different opening dates, or with different values such as introduction years.
Explanation
The Crystal Beach Cyclone example had two records with different introduction years.
- 35
How can a specific record be investigated using a condition on a column?
Model answer
Use the
querymethod with a condition, such as filtering rows where the coaster name equals a specified name.Explanation
This makes it possible to inspect all records associated with one coaster name.
- 36
How can only the first record be retained when duplicates are defined by several columns?
Model answer
Use
duplicated(subset=[...]), invert the Boolean result with~, and select the resulting rows.Explanation
The inverted mask keeps rows that are not duplicate occurrences for the selected subset.
- 37
Why is
reset_index(drop=True)useful after removing rows?Model answer
It creates a continuous new index and prevents the old index from being added as a separate column.
Explanation
Dropping rows can leave gaps in the original index.
- 38
What was the final size of the cleaned roller-coaster data set?
Model answer
It contained 990 unique roller coasters and 13 feature columns.
Explanation
Duplicate records were removed before the feature analysis began.
- 39
What is univariate analysis?
Model answer
Univariate analysis examines one feature or column at a time to understand its distribution and possible outliers.
Explanation
The tutorial first analyzes individual features before examining relationships between features.
- 40
What does the
value_counts()method do?Model answer
It counts how often each unique value occurs in a Series and orders the results from most frequent to least frequent.
Explanation
It is useful for identifying common and uncommon values in a feature.
- 41
What did
value_counts()reveal about the year roller coasters were introduced?Model answer
The year 1999 had the most entries, with 46 roller coasters, followed by 2000 and 1998.
Explanation
The counts show which introduction years were most common in the data set.
- 42
How can the most common years in a value-counts result be plotted?
Model answer
Apply
.head(10)to keep the ten most frequent values and then create a bar plot.Explanation
Plotting only the top ten years makes the chart easier to interpret.
- 43
What is the purpose of a bar plot of the top introduction years?
Model answer
It visually compares the number of roller coasters introduced in the most common years.
Explanation
The year appears on the horizontal axis and the count appears on the vertical axis.
- 44
Why are plot titles and axis labels important?
Model answer
They identify what the visualization represents and make the plotted values easier to interpret.
Explanation
The tutorial labels the year and count axes and adds descriptive titles.
- 45
What does a histogram show for a continuous feature such as speed?
Model answer
It shows how many observations fall into each interval, or bin, of the feature.
Explanation
Histograms are useful for examining the distribution of continuous numeric values.
- 46
Why might changing the number of histogram bins be useful?
Model answer
Different bin sizes can make important patterns in the distribution clearer or less cluttered.
Explanation
The tutorial uses 20 bins to obtain a clearer view of coaster speeds.
- 47
What pattern appeared in the roller-coaster speed distribution?
Model answer
Speeds around 40 to 50 miles per hour were common, with a particularly noticeable concentration near 50 miles per hour, and some much higher values appeared as possible outliers.
Explanation
The histogram helps identify both common speeds and unusually large values.
- 48
How does a kernel density estimate plot differ from a histogram?
Model answer
A kernel density estimate provides a smoothed, normalized representation of a distribution and is often easier to compare across multiple distributions.
Explanation
The speed density plot showed peaks similar to those seen in the histogram, including around 35 and 50 miles per hour.
- 49
What is the purpose of examining every feature individually during exploratory analysis?
Model answer
It helps reveal each feature's distribution, common values, missing data, and potential outliers before relationships are analyzed.
Explanation
The tutorial encourages repeating these individual-feature checks across the data set.
- 50
What does a scatter plot show when comparing two features?
Model answer
It represents each row as a point positioned according to the values of two selected features.
Explanation
The tutorial plots speed on one axis and height on the other.
- 51
What relationship was examined in the basic coaster scatter plot?
Model answer
The plot compared roller-coaster speed in miles per hour with height in feet.
Explanation
Each point represented one row in the data set.
- 52
Why might
plot.show()be added after creating a Pandas plot?Model answer
It displays the plot cleanly without printing the underlying Matplotlib object representation.
Explanation
Without it, notebook output may include information about the subplot object.
- 53
What additional capability does a Seaborn scatter plot provide over a basic plot?
Model answer
It can encode another variable through color, such as using introduction year as the plot's hue.
Explanation
Different colors show how the third variable varies across the speed-height relationship.
- 54
What is a Seaborn pair plot?
Model answer
It is a matrix of plots that compares multiple features pairwise and displays the distribution of each individual feature along the diagonal.
Explanation
Scatter plots show pairwise relationships while diagonal plots summarize individual distributions.
- 55
How can a pair plot display groups using color?
Model answer
Provide a categorical feature to the
hueparameter, such as the material used to build the coaster.Explanation
The colors distinguish wood, steel, and other material categories.
- 56
What pattern involving construction material and introduction year could be observed in the pair plot?
Model answer
Steel coasters were uncommon in the earliest years, began appearing around the 1950s, and became increasingly common later.
Explanation
Coloring points by material makes this temporal pattern visible.
- 57
What does a correlation value measure between two numeric features?
Model answer
It indicates the strength and direction of the relationship between the two features.
Explanation
Positive and negative values indicate different directions of association.
- 58
What correlation was reported between coaster speed and height?
Model answer
Their correlation was approximately 0.73, indicating a fairly strong positive relationship.
Explanation
The value suggests that taller coasters tend to be associated with higher speeds in this data set.
- 59
Why should null values be removed before calculating correlations in this analysis?
Model answer
Removing null values ensures that the correlation calculation uses complete paired observations.
Explanation
The tutorial drops missing values before applying the correlation function.
- 60
What does a correlation heat map display?
Model answer
It displays the correlations between multiple numeric features using color, often with the numeric correlation values annotated.
Explanation
The heat map provides a visual overview of relationships in the correlation data frame.
- 61
Why are the diagonal values of a correlation matrix equal to 1?
Model answer
Each feature has a perfect positive correlation with itself.
Explanation
The heat map therefore shows ones along its diagonal.
- 62
What analytical question was asked about roller-coaster locations?
Model answer
The question was which locations have the fastest average roller coasters, considering only locations with at least 10 coasters.
Explanation
This question demonstrates how exploratory analysis can lead to a targeted comparison.
- 63
Why was the location value
otherexcluded from the location analysis?Model answer
It does not represent a specific actual location, so including it would not provide a meaningful location comparison.
Explanation
The analysis filters out rows where location equals
other. - 64
How can records be organized for separate calculations by location?
Model answer
Filter the data as needed and use
groupbyon the location column.Explanation
Grouping creates a separate collection of coaster records for each location.
- 65
What statistics were calculated for speed within each location?
Model answer
The analysis calculated the mean speed and the count of roller coasters for each location.
Explanation
The mean measures average speed, while the count supports the minimum-size requirement.
- 66
How can multiple summary statistics be calculated during grouped analysis?
Model answer
Use the
aggmethod and specify the desired functions, such asmeanandcount, for the speed column.Explanation
Aggregation produces multiple summaries for every location group.
- 67
How was the minimum requirement of 10 roller coasters enforced?
Model answer
The grouped results were filtered to retain only locations whose coaster count was greater than or equal to 10.
Explanation
This prevents locations with very few coasters from dominating the comparison.
- 68
Why were the grouped results sorted by mean speed?
Model answer
Sorting by mean speed ranks the qualifying locations from slower to faster or vice versa, making the highest averages easy to identify.
Explanation
The sorted results show which locations have the fastest average coasters.
- 69
What type of plot was used to display average coaster speed by location?
Model answer
A horizontal bar plot was used, showing average speed for each qualifying location.
Explanation
A horizontal bar chart makes comparisons among location names easier to read.
- 70
Which location had the highest average roller-coaster speed among locations with at least 10 coasters?
Model answer
Busch Gardens had the highest average coaster speed, followed by Cedar Point.
Explanation
The grouped and filtered results answer the location-based research question.
- 71
Why is asking a specific question an important final step in exploratory data analysis?
Model answer
A specific question guides the analyst toward appropriate filtering, grouping, aggregation, and visualization methods.
Explanation
The location example shows how a question motivates the sequence of Pandas operations needed to obtain an answer.

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