Data Science Basics with Python
- 60Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is Anaconda?
A tool that simplifies setting up a data science environment by managing packages and dependencies.
Or swipe the card
60 cards
What is Anaconda?
A tool that simplifies setting up a data science environment by managing packages and dependencies.
What is a Jupyter notebook?
An interactive, web-based document that combines code, text (markdown), and visualizations in cells.
How do you create a new Jupyter notebook in VS Code?
Create a new file with .ipynb extension or use the command palette to create a new Jupyter notebook.
What is the purpose of markdown cells in a Jupyter notebook?
To add formatted text, headings, images, and documentation to explain the code and results.
How do you execute a code cell in a Jupyter notebook?
Press Shift+Enter or click the run button (triangle) next to the cell.
How do you create a Python list?
Using square brackets:
[item1, item2, ...].How do you print a variable in Python?
Use the
print()function:print(variable).What is the difference between multiplying a list by 2 and multiplying a numpy array by 2?
Multiplying a list duplicates its elements; multiplying a numpy array multiplies each element by 2.
How do you import numpy?
import numpy as npHow do you create a numpy array?
np.array([list])How do you get the shape of a numpy array?
array.shapereturns a tuple of dimensions (e.g., (22,) for a 1D array with 22 elements).What is the index of the first element in a numpy array?
0
How do you access a specific element in a 1D numpy array?
array[index]How do you create a 2D numpy array from two lists?
np.array([list1, list2])How do you access an element in a 2D numpy array?
array[row_index, col_index](e.g.,array[0,1]for first row, second column).How do you import pandas?
import pandas as pdWhat is a DataFrame?
A two-dimensional, tabular data structure with labeled rows and columns, similar to a spreadsheet.
How do you create a DataFrame from a dictionary?
pd.DataFrame({'column1': data1, 'column2': data2})How do you access a row in a DataFrame using its index label?
df.loc[row_label](e.g.,df.loc[0]for the first row).How do you access a column in a DataFrame?
df['column_name']ordf.column_name(if the name is a valid Python identifier).How do you access a specific value in a DataFrame?
df.loc[row_index, 'column_name']How do you filter rows in a DataFrame based on a condition?
df[df['column'] == value](or any boolean condition).How do you use the query method to filter a DataFrame?
df.query('column == "value"')(use double quotes for string values inside the query).How do you load a CSV file into a DataFrame?
pd.read_csv('filename.csv', delimiter=',', header=0)(or simplypd.read_csv('file.csv')).How do you check for null values in a DataFrame?
df.isnull()returns a DataFrame of booleans (True where null).How do you get the count of null values per column?
df.isnull().sum()How do you fill missing values in a column with the column mean?
df['column'].fillna(df['column'].mean())How do you drop all rows that contain any null values?
df.dropna(axis=0)(axis=0 for rows).How do you add a new column to a DataFrame based on a condition?
Create a boolean Series and assign it:
df['new_col'] = df['grade'] >= 60(example).How do you group data by a column and calculate the mean of another?
df.groupby('group_col')['value_col'].mean()How do you sort a DataFrame by a column?
df.sort_values('column', ascending=True)(use False for descending).How do you import matplotlib.pyplot?
import matplotlib.pyplot as pltHow do you create a simple bar chart in matplotlib?
plt.bar(x_values, heights)thenplt.show()How do you add a title and axis labels to a matplotlib plot?
plt.title('Title'),plt.xlabel('X label'),plt.ylabel('Y label')How do you rotate x‑axis labels in a matplotlib plot?
plt.xticks(rotation=90)(or any angle).How do you change the color of bars in a bar chart?
Add the
colorparameter:plt.bar(x, y, color='orange').How do you create a histogram?
plt.hist(data, bins=10)(bins optional) thenplt.show().How do you create a box plot?
plt.boxplot(data)ordf.boxplot(column='col').How do you create a scatter plot in matplotlib?
plt.scatter(x, y)thenplt.show()What is the difference between a figure and a plot in matplotlib?
A figure is the entire window; a plot (or axes) is a single chart within the figure.
How do you create subplots in matplotlib?
fig, axes = plt.subplots(nrows, ncols, figsize=(w,h)); then useaxes[0],axes[1], etc.How do you create a pie chart in matplotlib?
axes.pie(data, labels=labels)(e.g.,ax1.pie(counts, labels=['Fail','Pass'])).How do you plot directly from a pandas DataFrame?
df.plot(kind='bar', x='col1', y='col2', figsize=(w,h))(or other kinds like 'hist').How do you customize the size of a matplotlib figure?
Set
figsizeparameter:plt.figure(figsize=(width_inches, height_inches))or in subplots.What is the
describe()method in pandas?df.describe()returns summary statistics (count, mean, std, min, quartiles, max) for numeric columns.What is the mean of a dataset?
The arithmetic average: sum of all values divided by the number of values.
What is the median of a dataset?
The middle value when the data is sorted in ascending order (or average of two middle values if even count).
What is the mode of a dataset?
The value that appears most frequently in the dataset.
What is the range of a dataset?
The difference between the maximum and minimum values: max−min.
What is variance?
The average of the squared differences from the mean: n1∑i=1n(xi−xˉ)2.
How is standard deviation related to variance?
Standard deviation is the square root of the variance: σ=variance.
What percentage of data falls within one standard deviation of the mean in a normal distribution?
Approximately 68%.
How do you normalize data using MinMaxScaler?
from sklearn.preprocessing import MinMaxScaler;scaler = MinMaxScaler();scaler.fit_transform(data)How do you calculate the correlation between two columns in a DataFrame?
df['col1'].corr(df['col2'])What is the range of the correlation coefficient?
From -1 to 1, where -1 indicates perfect negative linear relationship, 0 no linear relationship, and 1 perfect positive linear relationship.
Does correlation imply causation?
No. Correlation does not mean one variable causes the other; there may be confounding factors.
What is linear regression in the form y=mx+b?
A model that describes the linear relationship between an independent variable x and a dependent variable y, where m is the slope and b is the y-intercept.
How do you obtain the slope and intercept of a linear regression using scipy?
from scipy import stats;slope, intercept, r, p, se = stats.linregress(x, y)How do you plot a regression line on a scatter plot?
First calculate predicted y:
y_pred = m * x + b. Then plot the line withplt.plot(x, y_pred, color='cyan').How do you predict a value using a linear regression model?
Use the equation y=mx+b with the calculated slope and intercept:
prediction = m * new_x + b.

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