Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Created January 5, 2014 15:48
Show Gist options
  • Select an option

  • Save shiumachi/8269821 to your computer and use it in GitHub Desktop.

Select an option

Save shiumachi/8269821 to your computer and use it in GitHub Desktop.
Hadoop等の時間表記をdatetimeオブジェクトに変換する
date_string = "2014-01-05 22:20:50,307"
def convert_to_datetime(date_string):
""" input: %Y-%m-%d %H:%M:%S,%f
example: 2014-01-05 22:20:50,307
return: datetime object
"""
date_format = "%Y-%m-%d %H:%M:%S,%f"
import datetime
return datetime.datetime.strptime(date_string, date_format)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment