🌍 Data Analytics · subject
Data Analytics Programming for Analytics with Python Syllabus
The Programming for Analytics with Python syllabus for Data Analytics in full: 5 chapters and 22 topics, every one listed below, plus 50 Programming for Analytics with Python flashcards with answers.
Programming for Analytics with Python syllabus: all 5 chapters
Expand any chapter to see its topics and sub-topics.
-
Python Fundamentals
4 topics- Variables and Data Types
- Control Flow
- Functions
- Data Structures
-
NumPy for Numerical Computing
4 topics- Arrays and ndarray
- Vectorized Operations
- Broadcasting
- Array Indexing and Slicing
-
Data Manipulation with Pandas
6 topics- Series and DataFrames
- Reading and Writing Data
- Indexing and Selection
- Filtering and Sorting
- GroupBy and Aggregation
- Merging and Joining DataFrames
-
Cleaning Data in Python
4 topics- Handling Missing Data
- String and Date Manipulation
- Reshaping Data
- Applying Functions and Mapping
-
Visualization Libraries
4 topics- Matplotlib Basics
- Seaborn for Statistical Plots
- Plotly for Interactive Charts
- Customizing Visuals
Data Analytics Programming for Analytics with Python flashcards — 50 questions with answers
In Python, what is the difference between a mutable and an immutable data type, and give one example of each?
A mutable object can be changed in place after creation; an immutable object cannot. Example mutable: list, dict, set. Example immutable: int, float, str, tuple.
What are Python's four built-in numeric/text scalar types used for variables, and how do you check a variable's type at runtime?
Common scalar types are int, float, bool, and str (complex also exists). You check a variable's type with the built-in function type(x), or test membership with isinstance(x, int).
What is dynamic typing in Python, and what does it imply about variable declarations?
Dynamic typing means a variable's type is determined at runtime by the value assigned, not declared in advance. The same name can be rebound to values of different types, and no explicit type declaration is required.
In Python control flow, what keyword combines an else with a nested if to create a multi-way branch, and what is its syntax?
The elif keyword. Syntax: if condition1: ... elif condition2: ... else: ... Each branch's block is indented; only the first true condition's block executes.
What is the difference between a for loop and a while loop in Python?
A for loop iterates over the items of an iterable (list, range, string, etc.) a definite number of times; a while loop repeats as long as a boolean condition remains True, used when the number of iterations is not known in advance.
What do the break and continue statements do inside a Python loop?
break immediately terminates the entire enclosing loop. continue skips the rest of the current iteration and jumps to the next iteration of the loop.
How do you define a function in Python, and what statement returns a value from it?
Use the def keyword: def name(parameters): followed by an indented body. The return statement sends a value back to the caller; without it (or a bare return), the function returns None.
What is the difference between a positional argument, a keyword argument, and a default parameter value in a Python function?
A positional argument is matched by order. A keyword argument is passed as name=value. A default parameter value (def f(x=10)) is used when the caller omits that argument.
What do *args and **kwargs mean in a Python function signature?
*args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dict. They let a function accept a variable number of arguments.
What is a lambda function in Python and when is it typically used?
A lambda is an anonymous, single-expression function written as lambda args: expression. It is typically used inline as a short throwaway function, e.g., as the key in sorted() or the argument to map, filter, or pandas apply.
Compare Python's list, tuple, set, and dict by mutability and ordering.
list: ordered, mutable, allows duplicates. tuple: ordered, immutable, allows duplicates. set: unordered, mutable, no duplicates. dict: ordered (by insertion, 3.7+), mutable, unique keys mapping to values.
What is a Python list comprehension and give its general syntax?
A concise way to build a list from an iterable. General syntax: [expression for item in iterable if condition], e.g., [x**2 for x in range(5) if x % 2 == 0].
How do you access a value in a Python dictionary, and how does d[key] differ from d.get(key)?
Both retrieve the value for a key. d[key] raises a KeyError if the key is missing, while d.get(key) returns None (or a supplied default) instead of raising an error.
What distinguishes a NumPy ndarray from a Python list?
An ndarray is a fixed-size, homogeneous (single dtype) N-dimensional array stored in contiguous memory, enabling fast vectorized operations. A Python list is a heterogeneous, dynamically sized container of object references and is slower for numerical work.
What do the ndarray attributes .shape, .ndim, .size, and .dtype each report?
.shape is a tuple of dimension lengths; .ndim is the number of dimensions (axes); .size is the total number of elements; .dtype is the data type of the elements.
Which NumPy functions create an array of all zeros, all ones, and an evenly spaced range, respectively?
np.zeros(shape) creates all zeros, np.ones(shape) creates all ones, and np.arange(start, stop, step) (or np.linspace(start, stop, num)) creates an evenly spaced range.
What is a vectorized operation in NumPy, and why is it faster than a Python loop?
A vectorized operation applies an element-wise operation to whole arrays at once (e.g., a + b) without an explicit Python loop. It is faster because the looping runs in optimized, compiled C code over contiguous memory rather than the Python interpreter.
If a and b are NumPy arrays of the same shape, what does a * b compute?
It computes the element-wise product: each element $c_i = a_i \times b_i$. It is NOT matrix multiplication (matrix product uses a @ b or np.dot).
What is broadcasting in NumPy?
Broadcasting is the set of rules by which NumPy performs element-wise operations on arrays of different shapes by virtually stretching the smaller array across the larger one, without copying data, so their shapes become compatible.
State the NumPy broadcasting rule for comparing two array shapes dimension by dimension.
Comparing shapes from the trailing (rightmost) dimensions, two dimensions are compatible when they are equal or one of them is 1. A dimension of size 1 is stretched to match the other; if neither condition holds, broadcasting fails with a ValueError.
Show the other 30 Programming for Analytics with Python flashcards
Given a of shape $(3,1)$ and b of shape $(1,4)$, what is the shape of a + b under broadcasting?
The result has shape $(3,4)$: the size-1 dimensions are each stretched to match the other array.
How does NumPy zero-based indexing let you access the element in row 2, column 3 of a 2D array a?
Use a[2, 3] (rows and columns are counted from 0). The comma separates the axis indices; a[2, 3] is the element in the third row and fourth column.
What does the slice a[1:5:2] return for a 1D NumPy array, and what do the three numbers mean?
It returns elements at indices 1 and 3 (start=1, stop=5 exclusive, step=2). The general form is start:stop:step, with stop excluded.
What is boolean (mask) indexing in NumPy, and give an example that selects positive values from array a?
It uses a boolean array of the same shape to select elements where the mask is True. Example: a[a > 0] returns a 1D array of all elements greater than zero.
In NumPy, does basic slicing return a view or a copy, and why does this matter?
Basic slicing returns a view that shares memory with the original array, so modifying the slice modifies the original. Fancy (integer/boolean) indexing returns a copy. Use .copy() to force an independent copy.
What is a pandas Series, and what two aligned components does it contain?
A Series is a one-dimensional labeled array holding a single dtype. It contains the values (a NumPy-like array) and an aligned index of labels used to access those values.
What is a pandas DataFrame, and how do its columns and index relate to Series?
A DataFrame is a two-dimensional labeled table with rows and columns. Each column is a Series that shares the DataFrame's row index; columns can have different dtypes.
Which pandas functions read a CSV file and an Excel file into a DataFrame?
pd.read_csv('file.csv') reads a CSV, and pd.read_excel('file.xlsx') reads an Excel spreadsheet.
How do you write a pandas DataFrame df to a CSV file without including the index column?
df.to_csv('output.csv', index=False). Setting index=False omits the DataFrame's row index from the written file.
In pandas, what is the difference between .loc and .iloc for selecting data?
.loc selects by label (row/column names) and is inclusive of the stop label; .iloc selects by integer position (0-based) and is exclusive of the stop position, like normal Python slicing.
How do you select a single column named 'age' from a DataFrame df as a Series, and how do you select multiple columns?
Single column: df['age'] (or df.age). Multiple columns: pass a list, df[['age', 'name']], which returns a DataFrame.
How do you filter a pandas DataFrame df to rows where the 'score' column exceeds 50?
Use boolean indexing: df[df['score'] > 50]. The inner expression creates a boolean mask that selects matching rows.
How do you combine two conditions when filtering a pandas DataFrame, and what must you remember about operators and parentheses?
Use the element-wise operators & (and), | (or), ~ (not), and wrap each condition in parentheses, e.g., df[(df['a'] > 0) & (df['b'] < 5)]. The Python keywords and/or do not work on Series.
How do you sort a DataFrame df by the 'age' column in descending order?
df.sort_values('age', ascending=False). Use by=['col1','col2'] to sort by multiple columns; sort_index() sorts by the index instead.
What does the pandas groupby operation do, described by the split-apply-combine paradigm?
groupby splits the data into groups based on key values, applies an aggregation or transformation to each group independently, and combines the results back into a Series or DataFrame.
Write a pandas expression that computes the mean 'salary' for each 'department' in df.
df.groupby('department')['salary'].mean(). It groups rows by department and averages the salary within each group.
How can you apply several aggregation functions at once to grouped data in pandas?
Use .agg with a list or dict, e.g., df.groupby('dept')['salary'].agg(['mean', 'max', 'count']) or df.groupby('dept').agg({'salary':'mean', 'age':'max'}).
In pandas merge, what do the how values 'inner', 'left', 'right', and 'outer' produce?
'inner' keeps only keys present in both frames; 'left' keeps all rows of the left frame; 'right' keeps all rows of the right frame; 'outer' keeps the union of keys from both, filling missing values with NaN.
What is the default join type of pd.merge, and how do you specify the column(s) to join on?
The default is an inner join. Specify the join key(s) with the on='col' parameter (or left_on / right_on when the key columns have different names).
What is the difference between pd.merge and pd.concat in pandas?
pd.merge combines DataFrames by matching values in key columns (database-style join). pd.concat stacks DataFrames along an axis (rows with axis=0 or columns with axis=1) based on index alignment, without key matching.
How do NaN values arise in pandas, and how do you detect them in a DataFrame df?
NaN (Not a Number) marks missing data, arising from reading incomplete files, reindexing, or outer joins. Detect them with df.isna() (or df.isnull()), often summarized as df.isna().sum() per column.
Contrast pandas dropna() and fillna() for handling missing data.
dropna() removes rows (or columns) that contain missing values. fillna(value) replaces missing values with a specified constant or a method like ffill (forward fill) or bfill (backward fill).
How do you replace missing values in the 'price' column of df with that column's mean?
df['price'] = df['price'].fillna(df['price'].mean()). This imputes each NaN with the arithmetic mean of the non-missing prices.
In pandas, how do you access string methods on a text column, and give an example that uppercases the 'name' column?
Use the .str accessor for vectorized string operations. Example: df['name'].str.upper(). Other methods include .str.lower(), .str.strip(), .str.contains(), and .str.split().
How do you convert a text column 'date' into pandas datetime objects, and why is that useful?
Use pd.to_datetime(df['date']). It enables datetime functionality: extracting components with the .dt accessor (.dt.year, .dt.month, .dt.dayofweek), sorting by time, and computing date differences.
What does the pandas .dt accessor provide, and give two example attributes?
The .dt accessor exposes datetime components and methods on a datetime Series. Examples: df['date'].dt.year returns the year, and df['date'].dt.day_name() returns the weekday name; .dt.month and .dt.hour are also common.
What is the difference between pandas pivot / pivot_table and melt for reshaping data?
pivot / pivot_table reshapes from long to wide format (spreading unique values of a column into new columns, with pivot_table also aggregating duplicates). melt does the reverse, unpivoting wide columns into long key-value rows.
In pandas reshaping, what do stack() and unstack() do?
stack() pivots the innermost column level down into the row index, producing a longer, narrower (often MultiIndex) result. unstack() does the opposite, moving an inner index level up into columns, producing a wider result.
In pandas, how does apply differ from map and applymap?
Series.map applies an element-wise function (or mapping dict) to each value of a Series. DataFrame.apply applies a function along an axis (to each column or row, often returning aggregates). DataFrame.applymap (or .map in newer pandas) applies a function element-wise across every cell.
Write a pandas statement that creates a new column 'category' by mapping values in 'code' using the dictionary {1:'A', 2:'B'}.
df['category'] = df['code'].map({1: 'A', 2: 'B'}). map replaces each code with its dictionary value, producing NaN for any code not found in the mapping.
Data Analytics Programming for Analytics with Python FAQ
What is in the Data Analytics Programming for Analytics with Python syllabus?
Data Analytics Programming for Analytics with Python is split into 5 chapters: Python Fundamentals, NumPy for Numerical Computing, Data Manipulation with Pandas, Cleaning Data in Python and Visualization Libraries. Together they contain 22 topics.
How many chapters are in Data Analytics Programming for Analytics with Python?
5 chapters, containing 22 topics. The largest chapter is Data Manipulation with Pandas, with 6 topics.
Are there flashcards for Data Analytics Programming for Analytics with Python?
Yes — a 50-card Programming for Analytics 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.