Introduction to Data Analysis Using Python
Core concepts
Python analysis centers on Jupyter notebooks and the pandas library. A DataFrame is a two-dimensional labeled table; a Series is a single labeled column. Typical workflow: import pandas as pd, load with pd.read_csv(), inspect with df.head(), df.shape, df.info(), and df.dtypes, then clean with df.dropna(), df.fillna(), df['col'].astype(), and df.drop_duplicates().
Summarize with df.describe(), df['col'].value_counts(), and df.groupby('col')['metric'].mean(). Combine tables with pd.merge(df1, df2, on='id', how='inner'), which mirrors SQL joins.
Selection is the highest-yield topic. .loc selects by label and is inclusive of the ending label; .iloc selects by integer position and excludes the end position. Boolean filtering with df[df['sales'] > 100] returns rows where the condition is true. Combine row and column selection with df.loc[df['region'] == 'West', 'sales'].
For visualization, import matplotlib.pyplot as plt and call plt.plot(), plt.bar(), plt.show(); seaborn adds statistical chart types. Remember that = assigns while == compares, and that inplace=True mutates the DataFrame rather than returning a new one.
Traps
Questions frequently test .loc versus .iloc and inclusive versus exclusive endpoints. Another trap is using a single equals sign inside a filter, or assuming dropna() preserves rows that merely contain empty strings.
Rule of thumb
Ask whether you are addressing rows by name or by position. Name means .loc; position means .iloc. If you are unsure of a column's type, check dtypes before filtering or merging.