A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 120 companion flashcards using spaced repetition.
The Pandas library (imported as import pandas as pd) provides the DataFrame, a two-dimensional, size-mutable, tabular data structure with labeled rows and columns. Think of it as a...
Before manipulating a DataFrame you usually inspect it. df.head() and df.tail(n) peek at the first and last rows (default five). df.shape returns a tuple (n_rows, n_cols), df.colum...
Adding a column is as simple as assigning to a new key: df['new'] = df['a'] + df['b']. To remove one, use df.drop('col', axis=1) or the in-place shortcut del df['col']. Renaming is...
The quickest overview of a numeric frame is df.describe(), which returns count, mean, standard deviation, min, quartiles, and max for every numeric column. For individual reduction...
Real datasets are rarely clean. df.isna() produces a boolean DataFrame marking every NaN cell, and df.isna().sum() counts NaNs per column so you can see where the holes are. To det...
The Split-Apply-Combine paradigm is encoded in df.groupby('key'). After grouping, aggregations like df.groupby('key').mean(numeric_only=True) or .sum() collapse each group into a s...
Date handling is a first-class concern in Pandas. Strings become datetimes with pd.to_datetime(df['date_str']), optionally sped up by passing an explicit format='%Y-%m-%d'. Once a...