Python One-Liners

How to Filter a List of Dictionaries in Python?

In this article, you’ll learn how to filter a list of dictionaries. So let’s get started! Short answer: The list comprehension statement [x for x in lst if condition(x)] creates a new list of dictionaries that meet the condition. All dictionaries in lst that don’t meet the condition are filtered out. You can define your …

How to Filter a List of Dictionaries in Python? 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 …

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