List Comprehensions and Lambda Functions
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.
- Read and work with JSON files.
- Learn to use list comprehensions to easily create and transform lists.
- Learn to create and use lambda functions.
- The JSON Format
- Reading a JSON file
- Deleting Dictionary Keys
- Writing List Comprehensions
- Using List Comprehensions to Transform and Create Lists
- Using List Comprehensions to Reduce a List
- Passing Functions as Arguments
- Lambda Functions
- Using Lambda Functions to Analyze JSON data
- Reading JSON files into pandas
- Exploring Tags Using the Apply Function
- Extracting Tags Using Apply with a Lambda Function
- Next Steps