parameters: (element: str, **kwargs)
return_statement: return fmt
docstring: Infers datetime format from a string, also takes cares for `ms` and `ns`
docstring_summary: Infers datetime format from a string, also takes cares for `ms` and `ns`
docstring_tokens: Infers datetime format from a string also takes cares for ms and ns
function: def infer_format(element: str, **kwargs) -> str:
      """
      Infers datetime format from a string, also takes cares for `ms` and `ns`
      """
      fmt = _guess_datetime_format(element, **kwargs)
  
      if fmt is not None:
          return fmt
  
      element_parts = element.split(".")
      if len(element_parts) != 2:
          raise ValueError("Given date string not likely a datetime.")
  
      # There is possibility that the element is of following format
      # '00:00:03.333333 2016-01-01'
      second_parts = re.split(r"(\D+)", element_parts[1], maxsplit=1)
      subsecond_fmt = ".%" + str(len(second_parts[0])) + "f"
  
      first_part = _guess_datetime_format(element_parts[0], **kwargs)
      # For the case where first_part is '00:00:03'
      if first_part is None:
          tmp = "1970-01-01 " + element_parts[0]
          first_part = _guess_datetime_format(tmp, **kwargs).split(" ", 1)[1]
      if first_part is None:
          raise ValueError("Unable to infer the timestamp format from the data")
  
      if len(second_parts) > 1:
          # "Z" indicates Zulu time(widely used in aviation) - Which is
          # UTC timezone that currently cudf only supports. Having any other
          # unsupported timezone will let the code fail below
          # with a ValueError.
          second_parts.remove("Z")
          second_part = "".join(second_parts[1:])
  
          if len(second_part) > 1:
              # Only infer if second_parts is not an empty string.
              second_part = _guess_datetime_format(second_part, **kwargs)
      else:
          second_part = ""
  
      try:
          fmt = first_part + subsecond_fmt + second_part
      except Exception:
          raise ValueError("Unable to infer the timestamp format from the data")
  
      return fmt
function_tokens: def infer_format ( element : str , * * kwargs ) -> str : fmt = _guess_datetime_format ( element , * * kwargs ) if fmt is not None : return fmt element_parts = element . split ( "." ) if len ( element_parts ) != 2 : raise ValueError ( "Given date string not likely a datetime." ) # There is possibility that the element is of following format # '00:00:03.333333 2016-01-01' second_parts = re . split ( r"(\D+)" , element_parts [ 1 ] , maxsplit = 1 ) subsecond_fmt = ".%" + str ( len ( second_parts [ 0 ] ) ) + "f" first_part = _guess_datetime_format ( element_parts [ 0 ] , * * kwargs ) # For the case where first_part is '00:00:03' if first_part is None : tmp = "1970-01-01 " + element_parts [ 0 ] first_part = _guess_datetime_format ( tmp , * * kwargs ) . split ( " " , 1 ) [ 1 ] if first_part is None : raise ValueError ( "Unable to infer the timestamp format from the data" ) if len ( second_parts ) > 1 : # "Z" indicates Zulu time(widely used in aviation) - Which is # UTC timezone that currently cudf only supports. Having any other # unsupported timezone will let the code fail below # with a ValueError. second_parts . remove ( "Z" ) second_part = "" . join ( second_parts [ 1 : ] ) if len ( second_part ) > 1 : # Only infer if second_parts is not an empty string. second_part = _guess_datetime_format ( second_part , * * kwargs ) else : second_part = "" try : fmt = first_part + subsecond_fmt + second_part except Exception : raise ValueError ( "Unable to infer the timestamp format from the data" ) return fmt