Lessons › Python
52 free lessons
Python lessons
Python for data analysts, from print() and loops to pandas, groupby, cleaning and charts.
- print()Show text and numbers
- VariablesGive a value a name
- MathsPython as a calculator
- Joining text with +Put pieces of text together
- .upper(), .lower() and .title()Change the capitals
- f-stringsPut values inside text
- ListsMany values in one variable
- len()Count the items
- sum(), min(), max()Total, lowest, highest
- .append()Add to a list
- Loops, step 1Do something for every item
- Loops, step 2Build up an answer
- ComparisonsTrue or False questions
- if and elseMake a decision
- elifMore than two outcomes
- Loops with ifPick items out while looping
- Functions, step 1Name a set of steps
- Functions, step 2Send back an answer with return
- Loading a CSVOpen a table in Python
- Looking at a tableSize, column names, last rows
- Picking a columnOne column by name
- Column totalsSum, average, biggest
- Counting valuesHow many of each
- Filtering, one conditionKeep only matching rows
- Filtering with &Both tests must pass
- Filtering with |One test is enough
- New columnsCalculate for every row
- SortingRank and take the top few
- groupby, part 1Totals for each group
- groupby, part 2Averages and counts per group
- groupby, part 3Ratios per group
- Removing spaces with .str.strip()Tidy every value at once
- Fixing capitals with .str.str.title(), .str.upper(), .str.lower()
- Missing valuesFind and fill the gaps
- DuplicatesCount every row once
- ChartsBar and line charts
- Joining two tablesAdd a column from another table
- DatesTurn text into real dates
- Sales by monthGroup by month, then growth
- Pivot tablesA grid of rows and columns
- Several totals at once.agg and grouping by two columns
- If/else columnsLabel every row with np.where
- Fixing data typesNumbers stored as text
- Picking rows and saving.isin, .str.contains, .loc and to_csv
- Automate a reportEverything together
- Left joinsKeep every row, find what didn't match
- Dropping rows and columns.drop(columns=...) and .dropna()
- Renaming and recoding.rename(columns=...) and .replace({...})
- Your own rule on every row.apply with a function
- Changing chosen rowsdf.loc[test, column] = value
- Splitting text.str.split() and .str[0]
- A first look at any table.describe(), .unique() and .idxmax()