code: def get_name_id_interactive(stop, df):
      
  
      # this is very fast, but searching in a list of ca. 2900 tuples might be also
      # fast enough, and that would mean removing some repeated preprocessing...
  
      # pick only entries containing the given stop substring in column stop_name
      df1 = df[df.stop_name.apply(lambda cell: stop.lower() in cell.lower())]
      df1 = df1.sort_values(by=['stop_name'])
      df1_len = len(df1)
      if df1_len == 1:
          result = {
              'stop_id': df1.iloc[0].stop_id,
              'stop_name': df1.iloc[0].stop_name
          }
          return result
      elif df1_len > 1:
          msg = 'Please pick one of the following matching stop names:'
          termcolor.cprint(msg, attrs=['bold'])
          fmt = '%%%dd. %%s' % len(str(df1_len))
          for i, (index, _id, stop_name) in enumerate(df1.itertuples()):
              print(fmt % (i, stop_name))
  
          try:
              msg = 'Please select index of desired stop '\
                    'in list above (0-%d): ' % (df1_len - 1)
              msg = termcolor.colored(msg, attrs=['bold'])
              result = raw_input(msg)
          except KeyboardInterrupt:
              print('')
              return
  
          try:
              i = int(result)
          except ValueError:
              msg = "'%s' is not an integer number." % result
              termcolor.cprint(msg, 'red', attrs=['bold'])
              return
  
          if not 0 <= i <= df1_len - 1:
              msg = 'Invalid index.'
              termcolor.cprint(msg, 'red', attrs=['bold'])
              return
  
          result = {
              'stop_id': df1.iloc[i].stop_id,
              'stop_name': df1.iloc[i].stop_name
          }
          return result
docs: Return VBB/BVG ID for given stop name in given table.
  
      Enter interactive dialog when result is not unique.