Learn Python by building a Spotify log analysis tool
On completion of the exercises in this course, you will have:
- Fluency in Python's idiomatic object-oriented coding style
- Familiarity with Python's syntax, control structures, generators, decorators, and metaclasses
- Proficieny utilizing Pandas and other critical data-handling tools such as regular expressions
- Patterns for writing testable and maintainable code
- Tools and techniques for debugging, understanding and refactoring existing codebases
The exercises are interspersed with a project to develop a data analysis tool, demonstrating how the Python skills you have acquired can be used to implement sophisticated functionality in a maintainable package.
Learning Outcomes
A student completing this course will be able to implement Python scripts, modules and packages using classes and unit tests. They will also have experience using the Pandas data analysis library.
This is demonstrated through the implementation of a command-line data analysis tool.
Prerequisites
This course assumes experience in software development, object-oriented programming, and the Bash command line via SSH.
Topic 1: Python's syntax and data types
Python's use of indentation; type checking and the scalar data types; f-strings and interpolation; types of equality; polymorphism and operator overloading; and Python's OO core.
Topic 2: Compound data types and control structures
Looping over lists, tuples, sets, and dictionaries; combining and unpacking lists using the + and * operators; shallow and deep copies of data; list comprehension for data transformation; iterators and iterables; sorting; and the match/case control flow.
Topic 3: Functions, lambdas and decorators
Positional and keyword arguments; variadic functions; variable scope and the LEGB rule; nonlocal and global variables; lambda functions; and function decorators.
Topic 4: Iterators, Iterables and Generators
The difference between an iterable and an iterator; list comprehensions vs generator expressions; transforming and processing data with generator expressions, list comprehension, map, filter and reduce; generators and yield; and an introduction to the itertools package.
Topic 5: Classes, Instances, Metaclasses and Attributes
Class creation and inheritance; bool, str, repr and eval; @property, @classmethod, and @staticmethod decorators; sortable and iterable objects; multiple inheritance and the method resolution order (MRO); inheritance and attribute name mangling; mixins vs inheritance; metaclass and the Abstract Base Class.
Topic 6: Dealing with data
Regular expression search and replace; filehandles and exception handling; reading, writing, parsing and validating CSVs; and Pandas - Series, DataFrames, GroupBy aggregation, transformation and filtering.
Topic 7: Productionization
Scripts, modules, packages, and namespace packages; argparse CLI library; debugging with assert; unit and lint testing; Python virtual environments; and a final project using all the concepts covered.