code: def get_input_types(df, col_types, target_field):
      """Get the input types for each field in the DataFrame that corresponds
      to an input type to be fed into the model.
  
      Valid values are ['text', 'categorical', 'numeric', 'datetime', 'ignore']
  
      # Arguments:
          df: A pandas DataFrame.
          col_types: A dict of explicitly defined {field_name: type} mappings.
          target_field: string indicating the target field
  
      # Returns:
          A dict of {field_name: type} mappings.
      """
  
      fields = df.columns
      nrows = df.shape[0]
      avg_spaces = -1
  
      field_types = OrderedDict()
  
      for field in fields:
          if field in col_types:
              field_types[field] = col_types[field]
              continue
          field_type = df[field].dtype
          num_unique_values = df[field].nunique()
          if field_type == "object":
              avg_spaces = df[field].str.count(" ").mean()
  
          # Automatically ignore `id`-related fields
          if field.lower() in ["id", "uuid", "guid", "pk", "name"]:
              field_types[field] = "ignore"
  
          # Foreign key fields are always categorical
          # else if "_id" in field or "_uuid" in field:
          #     field_types[field] = 'categorical'
  
          # Datetime is a straightforward data type.
          elif field_type == "datetime64[ns]":
              field_types[field] = "datetime"
  
          # Assume a float is always numeric.
          elif field_type == "float64":
              field_types[field] = "numeric"
  
          # If it's an object where the contents has
          # many spaces on average, it's text
          elif field_type == "object" and avg_spaces >= 2.0:
              field_types[field] = "text"
  
          # If the field has very few distinct values, it's categorical
          elif num_unique_values <= 10:
              field_types[field] = "categorical"
  
          # If the field has many distinct integers, assume numeric.
          elif field_type == "int64":
              field_types[field] = "numeric"
  
          # If the field has many distinct nonintegers, it's not helpful.
          elif num_unique_values > 0.9 * nrows:
              field_types[field] = "ignore"
  
          # The rest (e.g. bool) is categorical
          else:
              field_types[field] = "categorical"
  
      # Print to console for user-level debugging
      print("Modeling with field specifications:")
      print(
          "\n".join(
              [
                  "{}: {}".format(k, v)
                  for k, v in field_types.items()
                  if k != target_field
              ]
          )
      )
  
      field_types = {
          k: v for k, v in field_types.items() if v != "ignore"
      }
  
      return field_types
  
imports: import re
  import pandas
  import random
  import yaml
  import os
  import shutil
  from time import time
  from pkg_resources import resource_filename
  from tqdm import tqdm, tqdm_notebook
  from tqdm._utils import _term_move_up
  from subprocess import Popen, PIPE, DEVNULL, CalledProcessError
  from autopep8 import fix_code
  from collections import OrderedDict
label_desc: Use image node_id 1 for calling a global function with example usage: get_input_types(df, col_types, target_field) and returns: field_types