MISSION 355

List Comprehensions and Lambda Functions

In this mission, you'll learn about concepts such as working with data in JavaScript Object Notation, list comprehensions, lambda functions, and more to turbo-charge working with data in Python. 

One of the places that the JSON format is commonly used is in the results returned by an Application programming interface (API). APIs are interfaces used to send and transmit data between different computer systems. If you'd like to learn how to work with APIs, you can check out API course as well. Along with working with JSON data, you will also learn about the json library. The library provides functions that enable you to work with JSON data while using Python code. You will also learn what list comprehensions are and how they can be used to clean up your code and make it easier to read. List comprehensions can be used to: 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 which are defined as temporary functions that can be declared in a single line of code.

In this mission, you will work with data from Hacker News to give a thorough overview of regular expressions and how powerful they can be in your data cleaning tasks. Because you'll be working with real-world data, you will have the opportunity to think like a data analyst or data scientist as you explore a dataset. By the end of this mission, you will have a better working knowledge of list comprehensions and lambda functions and how to use them to do some powerful 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:

Intermediate

The median completion time for this course is 7 hours. View Details

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