Created
January 5, 2014 15:48
-
-
Save shiumachi/8269821 to your computer and use it in GitHub Desktop.
Hadoop等の時間表記をdatetimeオブジェクトに変換する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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