Data analysis with pandas
Load, clean, filter, group and chart data with pandas, NumPy and matplotlib, all running in your browser.
pandas is the most used Python tool for working with tables of data. This course starts from a small table and builds up to cleaning messy data, grouping, joining and drawing charts. pandas, NumPy and matplotlib load in your browser the first time you run a lesson's code, so there is nothing to install.
- 1What pandas is: your first DataFrameMeet pandas, the Python library for tables. Build your first DataFrame from a dictionary, look at its shape and columns and add up a column.12 min
- 2Series: one column of dataA Series is one column with labels. Create one, pick values by label, do maths on every value at once and count how often each value appears.13 min
- 3Reading a CSV file and a first lookLoad a CSV file with pd.read_csv, then get to know the data with head, tail, shape, columns and dtypes before you change anything.14 min
- 4Selecting columns and rows: loc and ilocPick the columns and rows you need: by column name, by row label with loc and by position with iloc, including single cells and slices.15 min
- 5Filtering rows with conditionsKeep only the rows you need with a condition, combine conditions with & and |, and use isin, between and str.contains for common filters.15 min
- 6Sorting and rankingSort a table by one or more columns, put the biggest values first, get the top rows with nlargest and give every row a rank number.12 min
- 7New columns and calculationsAdd columns calculated from other columns, use NumPy arrays and np.where for fast maths and choices, and build running totals and shares.16 min
- 8Missing data: isna, fillna, dropnaFind empty cells in a table, count them, fill them with a value or an average, or drop the rows, and see how sums and means treat NaN.14 min
- 9Cleaning text and typesTidy messy text with str methods, turn text into numbers with astype and to_numeric, and turn date strings into real dates with to_datetime.16 min
- 10groupby: totals and averages by groupSplit a table into groups and summarise each one: totals by shop, averages by class, several summaries at once with agg, and a bar chart.17 min
- 11Pivot tables and crosstabReshape a long list of sales into a summary grid with pivot_table, add totals with margins, and count combinations with pd.crosstab.14 min
- 12Merging and joining tablesCombine two tables on a shared column with pd.merge, choose inner, left or outer joins, spot rows with no match, and stack tables with concat.15 min
- 13Dates and time seriesBuild a series of dates, use dates as the index, pick days and months, total sales by week or month with resample and smooth with rolling.16 min
- 14Charts with matplotlib and df.plotDraw line, bar, scatter and histogram charts with matplotlib, add titles and labels, and chart a DataFrame straight away with df.plot.16 min
- 15Project: analyse a shop's salesPut the whole course together: load a messy sales file, check it, clean it, add totals, summarise by product and day and finish with a chart.22 min