Python List Methods Cheat Sheet [Instant PDF Download]

Here’s your free PDF cheat sheet showing you all Python list methods on one simple page. Click the image to download the high-resolution PDF file, print it, and post it to your office wall: I’ll lead you through all Python list methods in this short video tutorial: If you want to study the methods yourself, … Read more

How to Convert Two Lists Into A Dictionary

Want to convert two lists into a dictionary? Do the following: Zip the lists together using zip(list_1, list_2). Create a dictionary from the list of tuples using the constructor dict() on the result. In other words, call dict(zip(list_1, list_2)) to convert two lists into a dictionary. Try it yourself: Let’s dive into the code step-by-step. … Read more

How to Calculate the Column Standard Deviation of a DataFrame in Python Pandas?

Want to calculate the standard deviation of a column in your Pandas DataFrame? In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of variance: it’s the average squared deviation of the list elements from the average value. You can do this by using the pd.std() function that … Read more

How to Use Generator Expressions in Python Dictionaries

Imagine the following scenario: You work in law enforcement for the US Department of Labor, finding companies that pay below minimum wage so you can initiate further investigations. Like hungry dogs on the back of a meat truck, your Fair Labor Standards Act (FLSA) officers are already waiting for the list of companies that violated … Read more

Python List Average

Don’t Be Mean, Be Median. This article shows you how to calculate the average of a given list of numerical inputs in Python. In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of the average: sum over all values and divide them by the number of values. … Read more

100 Code Puzzles to Train Your Rapid Python Understanding

Some coders possess laser-like code understanding skills. They look at a piece of source code, and the meaning pops immediately into their great minds. If you present them with a new code snippet, they’ll tell you in a few seconds what it does. Since I’ve started to train this skill of rapid code understanding in … Read more

Python One-Liners: Sampling A 2D Python List (to Speed Up Machine Learning)

This is a tutorial video from my new book “Python One-Liners” with NoStarch press (San Francisco 2020). Grab your Python One-Liner Superpower now! (Amazon Link) Here’s the code that shows you how to sample a two-dimensional Python list—including only every other list element in the resulting two-dimensional Python list. All of this happens in a … Read more

The Ultimate Guide to Python Lists

The most important collection data type in Python is the list data type. You’ll use lists basically in all your future projects. So take your time and invest a good hour or so to study this guide carefully. Overview — Creating a List in Python There are many ways of creating a list in Python. … Read more