π freeCodeCamp Β· subject
freeCodeCamp Data Analysis with Python Syllabus
The Data Analysis with Python syllabus for freeCodeCamp in full: 4 chapters and 14 topics, every one listed below, plus 50 Data Analysis with Python flashcards with answers.
Data Analysis with Python syllabus: all 4 chapters
Expand any chapter to see its topics and sub-topics.
-
NumPy
3 topics- Arrays and Vectorization
- Indexing and Slicing
- Array Operations
-
Pandas
4 topics- Series and DataFrames
- Cleaning and Transforming Data
- Grouping and Aggregation
- Reading and Writing Data
-
Data Visualization
2 topics- Matplotlib
- Seaborn
-
Certification Projects
5 topics- Mean-Variance-Standard Deviation Calculator
- Demographic Data Analyzer
- Medical Data Visualizer
- Page View Time Series Visualizer
- Sea Level Predictor
freeCodeCamp Data Analysis with Python flashcards β 50 questions with answers
What is a NumPy ndarray and how does it differ from a Python list?
An ndarray is a fixed-size, N-dimensional array whose elements are all the same data type (dtype) stored in contiguous memory. Unlike Python lists, it supports fast vectorized element-wise operations implemented in C, uses far less memory, and cannot mix types.
What is vectorization in NumPy and why is it faster than a Python for-loop?
Vectorization means applying an operation to an entire array at once (e.g., $a + b$, $a^{2}$) instead of looping element by element. The loop is executed in optimized, compiled C code with contiguous memory access, avoiding Python's per-element interpreter overhead.
Name the NumPy functions to create: an array of zeros, an array of evenly spaced values with a step, and an array of $n$ evenly spaced values between two endpoints.
np.zeros(shape) creates zeros; np.arange(start, stop, step) creates values with a fixed step (stop excluded); np.linspace(start, stop, n) creates exactly $n$ evenly spaced values including both endpoints.
What is broadcasting in NumPy?
Broadcasting is the rule set that lets NumPy operate on arrays of different shapes: dimensions are compared from the right, and two dimensions are compatible if they are equal or one of them is 1, in which case the size-1 dimension is stretched. Example: a $3 \times 3$ matrix plus a length-3 row vector adds the vector to every row.
In NumPy, what do the array attributes shape, ndim, size, and dtype tell you?
shape: a tuple of the array's dimensions (e.g., $(3, 4)$); ndim: the number of dimensions/axes; size: the total number of elements ($3 \times 4 = 12$); dtype: the data type of the elements (e.g., int64, float64).
How do you select the element in row 1, column 2 of a 2-D NumPy array a, and what does a[0] return?
Use a[1, 2] (comma-separated indices, zero-based). a[0] returns the entire first row as a 1-D array.
What does the slice a[start:stop:step] return, and is the stop index included?
It returns elements from index start up to but NOT including stop, taking every step-th element. Omitted parts default to start=0, stop=len, step=1; a negative step (e.g., a[::-1]) reverses the array.
What is boolean (mask) indexing in NumPy/pandas? Give an example.
Selecting elements with a boolean array of the same shape: a[a > 5] returns only the elements greater than 5. The comparison a > 5 is itself vectorized and produces a boolean mask; masks combine with & (and), | (or), ~ (not), each condition in parentheses.
Key difference between slicing a NumPy array and fancy/boolean indexing: which returns a view and which returns a copy?
Basic slicing returns a VIEW β modifying the slice modifies the original array. Fancy indexing (with integer arrays) and boolean indexing return a COPY, so changes do not affect the original.
In pandas, what is the difference between .loc and .iloc?
.loc selects by LABEL (index/column names) and its slices are inclusive of the stop label; .iloc selects by integer POSITION (zero-based) and its slices exclude the stop position, like Python slicing.
What does it mean that NumPy arithmetic operators like +, -, *, / are element-wise, and how do you do true matrix multiplication?
a * b multiplies corresponding elements: $c_{ij} = a_{ij} \, b_{ij}$ (Hadamard product). Matrix multiplication uses the @ operator or np.dot: $(AB)_{ij} = \sum_{k} a_{ik} b_{kj}$.
In NumPy aggregation functions on a 2-D array, what do axis=0 and axis=1 mean?
axis=0 collapses the rows, computing the statistic down each COLUMN (result has one value per column); axis=1 collapses the columns, computing across each ROW (one value per row). No axis argument aggregates over the entire flattened array.
What are NumPy universal functions (ufuncs)? Give three examples.
Ufuncs are functions that operate element-wise on arrays with broadcasting support, e.g., np.sqrt ($\sqrt{x}$), np.exp ($e^{x}$), np.log ($\ln x$), np.sin, np.abs. They return a new array of the same shape.
What do reshape, flatten, and transpose do to a NumPy array?
reshape(m, n) returns the same data in a new $m \times n$ shape (a dimension of $-1$ is inferred automatically); flatten() returns a 1-D copy; transpose (a.T) swaps axes so $(a^{T})_{ij} = a_{ji}$, turning an $m \times n$ array into $n \times m$.
What is a pandas Series and how does it relate to a DataFrame?
A Series is a 1-D labeled array: values plus an index. A DataFrame is a 2-D table of rows and columns where each column is a Series sharing the same row index; df['col'] returns that column as a Series.
Which pandas methods give a quick first look at a DataFrame's contents, structure, and summary statistics?
df.head(n) / df.tail(n) show the first/last rows; df.info() shows column dtypes, non-null counts, and memory usage; df.describe() shows count, mean, std, min, quartiles ($25\%$, $50\%$, $75\%$), and max for numeric columns; df.shape gives (rows, columns).
How do you create a DataFrame from a Python dictionary, and what do the dict keys become?
pd.DataFrame({'name': [...], 'age': [...]}) β each key becomes a COLUMN name and each value list becomes that column's data; rows get a default integer index 0, 1, 2, ... unless index= is passed.
What do value_counts(), unique(), and nunique() return for a pandas Series?
value_counts(): the frequency of each distinct value, sorted descending (normalize=True gives proportions); unique(): an array of the distinct values; nunique(): the count of distinct values.
Which pandas methods detect and remove missing values, and which method fills them?
isnull()/isna() return a boolean mask of missing values (notnull() is the inverse); dropna() removes rows (or columns with axis=1) containing NaN; fillna(value) replaces NaN with a given value or statistic such as the column mean.
In pandas, what is the difference between apply(), map(), and replace() for transforming data?
Series.map() applies a function or dict lookup element-wise to one Series; apply() applies a function along a Series or DataFrame axis (rows/columns); replace() substitutes specific values with others (scalars, lists, or dicts) without needing a function.
Show the other 30 Data Analysis with Python flashcards
How do you remove duplicate rows and convert a column's data type in pandas?
df.drop_duplicates() removes duplicate rows (subset= restricts the columns checked, keep= chooses which occurrence survives); df['col'].astype(int) (or float, str, 'category') converts the column's dtype; pd.to_datetime(df['col']) parses dates.
Give two common pandas string-cleaning operations using the .str accessor.
df['col'].str.strip() removes leading/trailing whitespace; .str.lower()/.str.upper() normalize case; .str.replace(old, new) substitutes substrings; .str.contains(pattern) returns a boolean mask for filtering. The .str accessor applies the operation to every element of the Series.
What is the split-apply-combine paradigm implemented by df.groupby()?
SPLIT the rows into groups by the values of one or more keys, APPLY a function (aggregation like mean/sum, transformation, or filtering) to each group independently, then COMBINE the results into a new Series or DataFrame indexed by the group keys.
How do you compute multiple aggregations at once after a groupby in pandas?
Use .agg(): df.groupby('key')['col'].agg(['mean', 'sum', 'count']), or a dict mapping columns to functions, e.g., df.groupby('key').agg({'price': 'mean', 'qty': 'sum'}). Each aggregation becomes a column in the result.
What is the difference between groupby().agg() and groupby().transform()?
agg() reduces each group to one value per group, shrinking the result to one row per group; transform() returns a result with the SAME shape as the original DataFrame, broadcasting each group's value back to its rows β useful for adding a group statistic (e.g., group mean) as a new column.
What does pd.pivot_table do, and what are its main parameters?
It creates a spreadsheet-style summary: values= the column to aggregate, index= the row grouping key(s), columns= the column grouping key(s), aggfunc= the aggregation (default mean). Equivalent to a groupby on two keys reshaped into a 2-D table.
Which pandas functions read and write CSV files, and how do you avoid writing the index?
pd.read_csv('file.csv') reads (key params: sep, header, names, index_col, parse_dates, na_values); df.to_csv('file.csv', index=False) writes without the row index column.
In pd.read_csv, what do the parameters index_col, parse_dates, and na_values do?
index_col sets a column as the DataFrame index; parse_dates converts the listed columns to datetime64; na_values specifies extra strings (e.g., '?', 'N/A') to treat as NaN on load.
Besides CSV, name three other data formats pandas can read and their functions.
Excel: pd.read_excel (sheet_name selects a sheet); JSON: pd.read_json; SQL: pd.read_sql with a database connection; also read_html for HTML tables and read_parquet. Each has a matching to_* writer method.
In Matplotlib, what is the difference between a Figure and an Axes?
The Figure is the whole canvas/window that can contain one or more plots; an Axes is a single plot area with its own x-axis, y-axis, title, and data. fig, ax = plt.subplots() creates one figure with one axes; plt.subplots(2, 2) creates a $2 \times 2$ grid of axes.
Which Matplotlib functions create a line plot, scatter plot, bar chart, and histogram?
plt.plot(x, y) β line; plt.scatter(x, y) β scatter; plt.bar(x, height) β bar chart (barh for horizontal); plt.hist(data, bins=n) β histogram of a distribution.
How do you add a title, axis labels, and a legend to a Matplotlib plot?
plt.title('...') (or ax.set_title), plt.xlabel('...') and plt.ylabel('...') (or ax.set_xlabel/set_ylabel), and plt.legend() after giving each plotted series a label= argument. plt.savefig('name.png') saves the figure to a file.
What is the difference between Matplotlib's pyplot (state-based) interface and the object-oriented interface?
pyplot (plt.plot, plt.title) implicitly operates on the 'current' figure/axes β convenient for quick plots; the object-oriented interface creates explicit objects (fig, ax = plt.subplots(); ax.plot(...); ax.set_title(...)), which is clearer and required when managing multiple subplots.
What is Seaborn and how does it relate to Matplotlib?
Seaborn is a statistical visualization library built ON TOP of Matplotlib. It provides high-level functions that work directly with pandas DataFrames (data=, x=, y=, hue= arguments), attractive default styles, and automatic aggregation/statistical estimation; the output is still Matplotlib figures/axes that can be customized with Matplotlib calls.
What does the hue parameter do in Seaborn plotting functions?
hue maps a categorical (or numeric) column to COLOR, splitting the plot into one colored group per category with an automatic legend β e.g., sns.scatterplot(data=df, x='age', y='income', hue='gender') colors points by gender.
Which Seaborn functions visualize a distribution, a category-vs-value comparison, and a correlation matrix?
Distribution: sns.histplot or sns.kdeplot (sns.displot is the figure-level version); category comparisons: sns.boxplot, sns.barplot (bar height = mean with a confidence interval), sns.countplot (frequencies); correlation matrix: sns.heatmap(df.corr(), annot=True) with colors encoding values.
In Seaborn, what is the difference between catplot (figure-level) and boxplot/barplot (axes-level) functions?
Axes-level functions draw onto a single Matplotlib Axes and can be placed in existing subplots; figure-level functions like catplot, relplot, and displot create their own figure and support faceting with col= and row= to produce a grid of subplots split by category. catplot's kind= parameter ('bar', 'box', 'count', ...) selects the underlying plot.
freeCodeCamp Mean-Variance-Std Calculator: what must the calculate() function do with its input, and when must it raise an error?
It takes a list of exactly 9 numbers, converts it to a $3 \times 3$ NumPy array, and returns a dictionary with mean, variance, standard deviation, max, min, and sum β each computed along axis=0 (columns), axis=1 (rows), and for the flattened array (values as lists). If the list does not contain 9 numbers it must raise a ValueError with the message 'List must contain nine numbers.'
State the formulas for population variance and standard deviation used by np.var and np.std (default ddof=0).
Variance: $$\sigma^{2} = \frac{1}{N} \sum_{i=1}^{N} (x_{i} - \mu)^{2}$$ where $\mu = \frac{1}{N}\sum_{i=1}^{N} x_{i}$. Standard deviation: $\sigma = \sqrt{\sigma^{2}}$. By default NumPy divides by $N$ (population); ddof=1 gives the sample version dividing by $N-1$.
How do you convert a flat list of 9 numbers into the $3 \times 3$ array needed for the Mean-Variance-Std Calculator?
np.array(list).reshape(3, 3) β np.array converts the list to an ndarray and reshape(3, 3) reorganizes it into 3 rows and 3 columns (row-major order: the first three values become row 0).
Demographic Data Analyzer: how do you compute the percentage of people with a Bachelor's degree from the census DataFrame?
Filter with a boolean mask and use the mask's mean or length ratio: $$\text{pct} = \frac{(\text{df['education']} == \text{'Bachelors'}).sum()}{\text{len(df)}} \times 100$$ rounded to 1 decimal β the standard count-matching-rows / total-rows pattern used throughout the project.
Demographic Data Analyzer: how do you find the country with the highest percentage of people earning >50K?
Compute per-country rich counts over per-country totals with value_counts (or groupby): rich_pct = df[df['salary'] == '>50K']['native-country'].value_counts() / df['native-country'].value_counts() * 100, then take .idxmax() for the country name and .max() for the percentage.
In pandas, what is the difference between idxmax() and max()?
max() returns the largest VALUE in a Series; idxmax() returns the INDEX LABEL where that maximum occurs β e.g., in the Demographic Data Analyzer, series.idxmax() gives the country name while series.max() gives its percentage. (idxmin/min are the analogues for the smallest value.)
Medical Data Visualizer: how are the overweight and BMI defined, and how are cholesterol/gluc normalized?
BMI $= \frac{\text{weight (kg)}}{\text{height (m)}^{2}}$; overweight $= 1$ if BMI $> 25$, else $0$. Cholesterol and gluc are normalized so 0 = good and 1 = bad: value 1 becomes 0, values $> 1$ become 1.
Medical Data Visualizer: what do pd.melt and sns.catplot do in the categorical plot step?
pd.melt reshapes the DataFrame from wide to long format β the six lifestyle columns (cholesterol, gluc, smoke, alco, active, overweight) become variable/value pairs with 'cardio' kept as id_vars. sns.catplot(kind='count', x='variable', hue='value', col='cardio') then draws count bars for each variable, split by value, in separate panels for cardio = 0 and 1.
Medical Data Visualizer: how is the data cleaned before the correlation heatmap, and how is only the lower triangle shown?
Keep rows where ap_lo $\leq$ ap_hi and where height and weight lie within the 2.5thβ97.5th percentiles (df['height'].quantile(0.025) to quantile(0.975)). Then compute corr = df.corr(), build a mask with np.triu(np.ones_like(corr, dtype=bool)) to hide the upper triangle, and draw sns.heatmap(corr, mask=mask, annot=True, fmt='.1f').
Page View Time Series Visualizer: how is the data cleaned before plotting?
Load fcc-forum-pageviews.csv with the date column parsed as datetime and set as the index, then filter OUT the extreme days: keep only rows where page views are between the 2.5th and 97.5th percentiles, i.e., df[(df['value'] >= df['value'].quantile(0.025)) & (df['value'] <= df['value'].quantile(0.975))].
Page View Time Series Visualizer: what three plots does the project require and what does each show?
(1) Line plot of daily page views over time; (2) bar plot of the AVERAGE daily page views for each month grouped by year (df.groupby([year, month]).mean(), legend of month names); (3) two side-by-side box plots β year-wise (trend across years) and month-wise (seasonality JanβDec) β built from a long-format DataFrame with sns.boxplot.
Sea Level Predictor: what does scipy.stats.linregress return, and how is the line of best fit used to predict sea level in 2050?
linregress(x, y) returns slope, intercept, rvalue, pvalue, and stderr for the least-squares line $$y = \text{slope} \cdot x + \text{intercept}.$$ The prediction plugs in the year: sea level in 2050 $\approx \text{slope} \times 2050 + \text{intercept}$; the fitted line is plotted over a scatter of the CSIRO data.
Sea Level Predictor: why are TWO regression lines fitted, and over what ranges are they drawn?
The first line uses ALL data (from 1880) to show the long-term trend; the second uses only data from year 2000 onward to capture the recent, steeper rate of rise. Both lines are extended to 2050 to compare predictions β the recent-data line predicts a higher 2050 sea level, showing the rate of rise has increased.
freeCodeCamp Data Analysis with Python FAQ
What is in the freeCodeCamp Data Analysis with Python syllabus?
freeCodeCamp Data Analysis with Python is split into 4 chapters: NumPy, Pandas, Data Visualization and Certification Projects. Together they contain 14 topics.
How many chapters are in freeCodeCamp Data Analysis with Python?
4 chapters, containing 14 topics. The largest chapter is Certification Projects, with 5 topics.
Are there flashcards for freeCodeCamp Data Analysis with Python?
Yes β a 50-card Data Analysis with Python deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.