Python for data and apps
NumPy, pandas and plotting, SQLite, logging, and small web apps with Flask and Streamlit.
Python's libraries for data and small apps: NumPy arrays and pandas tables, charts with Matplotlib and Seaborn, a SQLite database and logging, then web apps with Flask and Streamlit. Run the notebook cells in order; the Flask and Streamlit lessons run scripts from a terminal. Try each practice task before you open its solution.
Lessons
- 1NumPy arraysCreate arrays, read their shape, compute on whole arrays, slice rows and columns, and pick values with a condition.
- 2pandas: Series and DataFramesBuild Series and DataFrames, read and change rows and columns with
loc,iloc,atandiat, and load a CSV file. - 3Cleaning and summarising dataFind and fill missing values, rename columns and fix types, filter and sort rows, summarise groups with
groupby, and join tables withmerge. - 4Reading and writing dataRead JSON text, a CSV file from a URL, tables from a web page and an Excel workbook, and write DataFrames back to JSON, CSV, Excel and pickle.
- 5Plotting with MatplotlibLine plots and their styles, several plots in one figure, bar charts, histograms, scatter plots and pie charts, and plotting a DataFrame.
- 6Statistical plots with SeabornScatter and line plots, bar, box and violin plots per category, histograms and density curves, a pairplot and a correlation heatmap.
- 7SQLite databasesCreate a table, insert, query, update and delete rows, commit transactions, pass values safely with placeholders, and close the connection.
- 8LoggingLog levels,
basicConfigwith a format and a log file, named loggers with their own levels, and one logging setup shared by every module. - 9Flask: routes and templatesA first Flask app, routes, the development server and debug mode, HTML responses and templates from a
templatesfolder. - 10Flask: forms, URL variables and JinjaHandle GET and POST, read form fields safely, take typed values from the URL, fill templates with
{{ }},{% if %}and{% for %}, and redirect after a form. - 11Flask: a JSON APIBuild a to-do API with GET, POST, PUT and DELETE routes, return JSON with
jsonify, read JSON bodies withrequest.json, and call it from Python withrequests. - 12Streamlit appsRun a Streamlit app, show text, tables and charts, take input with widgets, and understand why the whole script reruns on every change.