Installation and Import
Pandas Data Structures
Series (1D)
ASeries is a one-dimensional labeled array. Unlike a Python list, it comes with built-in statistical methods.
DataFrame (2D)
ADataFrame is a two-dimensional table with labeled rows and columns — think of it as a spreadsheet or SQL table in Python. Unlike a NumPy 2D array, a DataFrame can hold different data types in different columns.
Creating DataFrames from Files
Exploring a Dataset
Accessing Data
loc[] — Label-Based Indexing
loc uses row labels and column names. Slicing with loc is inclusive of both endpoints.
iloc[] — Integer Position-Based Indexing
iloc uses integer positions. Slicing is exclusive of the upper bound (Python-style).
at[] and iat[] — Fast Scalar Access
Column Access
Prefer bracket notation
df['column'] over dot notation df.column. Dot notation fails silently when a column name contains spaces or matches a built-in DataFrame attribute.Filtering Data
Updating and Transforming Data
Updating with loc
Transforming with apply()
Faster Conditionals with np.where()
For simple conditions, np.where() is significantly faster than apply() because it is fully vectorized.