code: def _clean_data(data):
      # Make column names snake case
      clean_data = data.rename(
          columns={col: convert(col) for col in data}
      )
  
      # Chance crs -> "scheduled" and other minor clarifications
      clean_data = clean_data.rename(
          columns={
              "crs_arr_time": "scheduled_arr_time",
              "crs_dep_time": "scheduled_dep_time",
              "crs_elapsed_time": "scheduled_elapsed_time",
              "nas_delay": "national_airspace_delay",
              "origin_city_name": "origin_city",
              "dest_city_name": "dest_city",
              "cancelled": "canceled",
          },
      )
  
      # Combine strings like 0130 (1:30 AM) with dates (2017-01-01)
      clean_data["scheduled_dep_time"] = clean_data[
          "scheduled_dep_time"
      ].apply(lambda x: str(x),) + clean_data["flight_date"].astype(
          "str"
      )
  
      # Parse combined string as a date
      clean_data.loc[:, "scheduled_dep_time"] = pd.to_datetime(
          clean_data["scheduled_dep_time"],
          format="%H%M%Y-%m-%d",
          errors="coerce",
      )
  
      clean_data["scheduled_elapsed_time"] = pd.to_timedelta(
          clean_data["scheduled_elapsed_time"],
          unit="m",
      )
  
      clean_data = _reconstruct_times(clean_data)
  
      # Create a time index 6 months before scheduled_dep
      clean_data.loc[:, "date_scheduled"] = pd.to_datetime(
          clean_data["scheduled_dep_time"],
      ).dt.date - pd.Timedelta("120d")
  
      # A null entry for a delay means no delay
      clean_data = _fill_labels(clean_data)
  
      # Nulls for scheduled values are too problematic. Remove them.
      clean_data = clean_data.dropna(
          axis="rows",
          subset=["scheduled_dep_time", "scheduled_arr_time"],
      )
  
      # Make a flight id. Define a flight as a combination of:
      # 1. carrier 2. flight number 3. origin airport 4. dest airport
      clean_data.loc[:, "flight_id"] = (
          clean_data["carrier"]
          + "-"
          + clean_data["flight_num"].apply(lambda x: str(x))
          + ":"
          + clean_data["origin"]
          + "->"
          + clean_data["dest"]
      )
  
      column_order = [
          "flight_id",
          "flight_num",
          "date_scheduled",
          "scheduled_dep_time",
          "scheduled_arr_time",
          "carrier",
          "origin",
          "origin_city",
          "origin_state",
          "dest",
          "dest_city",
          "dest_state",
          "distance_group",
          "dep_time",
          "arr_time",
          "dep_delay",
          "taxi_out",
          "taxi_in",
          "arr_delay",
          "diverted",
          "scheduled_elapsed_time",
          "air_time",
          "distance",
          "carrier_delay",
          "weather_delay",
          "national_airspace_delay",
          "security_delay",
          "late_aircraft_delay",
          "canceled",
      ]
  
      clean_data = clean_data[column_order]
  
      return clean_data
  
file_path: featuretools/featuretools/demo/flight.py
imports: import math
  import re
  import pandas
  from tqdm import tqdm
  from woodwork.logical_types import Boolean, Categorical, Ordinal
  import featuretools
label_desc: Use image node_id 3 for calling a global function with example usage: _clean_data(data) and returns: clean_data