MISSION 355

List Comprehensions and Lambda Functions

In this mission, you'll learn about lambda functions and list comprehensions, two techniques you can use to turbo-charge your data cleaning in Python.

You'll learn how to work with data in the JavaScript Object Notation (JSON) format, which is commonly used for data acquired via web APIs (for more on working with APIs, check out our API course). As you work with JSON data, you learn to use the json library in Python. This library has built-in functions that make it easy to work with JSON data using Python code.

As you work with this JSON data, you will also learn about list comprehensions and how they can be used to clean up your code and make it easier to read. A list comprehension can be used to do things like iterate over values in a list, perform a transformation on those values, and assign the result to a new list all on one line of code! After you learn about list comprehensions, you will learn about lambda functions: temporary functions that can also be declared in a single line of code to save time.

In this mission, you will continue working with data from Hacker News as you practice using regular expressions and apply your new skills with list comprehensions and lambda functions. By the end of this mission, you'll be comfortable working with JSON data, and using list comprehensions and lambda functions to speed up your data cleaning.

Objectives

  • Read and work with JSON files.
  • Learn to use list comprehensions to easily create and transform lists.
  • Learn to create and use lambda functions.

Mission Outline

1. The JSON Format
2. Reading a JSON file
3. Deleting Dictionary Keys
4. Writing List Comprehensions
5. Using List Comprehensions to Transform and Create Lists
6. Using List Comprehensions to Reduce a List
7. Passing Functions as Arguments
8. Lambda Functions
9. Using Lambda Functions to Analyze JSON data
10. Reading JSON files into pandas
11. Exploring Tags Using the Apply Function
12. Extracting Tags Using Apply with a Lambda Function
13. Next Steps
14. Takeaways

python-data-cleaning-advanced

Course Info:

Python Data Cleaning Advanced

Intermediate

The average completion time for this course is 6–8-hours.

This course requires a basic subscription and includes four missions. It is the sixth course in the Data Analyst in Python Path and Data Scientist in Python Path

START LEARNING FREE

Take a Look Inside