Introduction to Code Workbook4. Write Your Transform
Feedback

4 - Write your Transform

This content is also available at learn.palantir.com ↗ and is presented here for accessibility purposes.

📖 Task Introduction

You should now see a code editor at the bottom of the page. There is a new Python function with the current dataset specified as an input. This function will perform a transformation on the input dataset(s) and output a new dataset as the result. In this code, we will filter our flights data to freight flights, defined as flights that traveled a distance > 2000 miles.

🔨 Task Instructions

  1. Copy and paste the following code snippet into your editor completely replacing the default code block.

    def us_freight_flights(flights):
        df = flights
        df = df.filter(df.distance > 2000)
        return df
    
  2. Click the blue ▶ Preview button.

  3. After the transform has completed running, click on the Preview tab at the bottom of the code editor to preview the dataset output of your transform.