🌍 Data Analytics · flashcards
Data Analytics Programming for Analytics with Python Flashcards
50 question-and-answer cards covering Programming for Analytics with Python as it is examined in Data Analytics. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.
24 sample cards from the Programming for Analytics with Python deck
Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.
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.
What this deck covers
The Programming for Analytics with Python deck follows the Data Analytics Programming for Analytics with Python syllabus — 5 chapters and 22 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 10.0 cards per chapter.
Answers are written to be recallable, not just readable — averaging about 172 characters, which is long enough to carry the reasoning and short enough to say out loud.
A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.
Programming for Analytics with Python flashcards FAQ
How many Programming for Analytics with Python flashcards are in this Data Analytics deck?
50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.
Are these Data Analytics flashcards free?
Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.
What do the Programming for Analytics with Python cards cover?
They follow the Data Analytics Programming for Analytics with Python syllabus — 5 chapters and 22 topics — so the questions track what is actually examinable.
How should I use these flashcards?
Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.