code: def datetime_to_nanos(dt):
      
      if isinstance(dt, pd.Timestamp):
          return dt.value
      elif isinstance(dt, str):
          return pd.Timestamp(dt).value
      elif isinstance(dt, long):
          return dt
      elif isinstance(dt, datetime):
  	return long(dt.strftime("%s%f")) * 1000
  
      raise ValueError
docs: Accepts a string, Pandas Timestamp, or long, and returns nanos since the epoch.