Tuesday, December 19, 2017

Python date time

>>> from dateutil.parser import parse
Traceback (most recent call last):
  File "", line 1, in

ImportError: No module named dateutil.parser

https://stackoverflow.com/questions/20853474/importerror-no-module-named-dateutil-parser

On Ubuntu you may need to install the package manager pip first:
sudo apt-get install python-pip
Then install the python-dateutil package with:
pip install python-dateutil
Converting strings to datetime
https://chrisalbon.com/python/strings_to_datetime.html
Python lib - basic dater times
https://docs.python.org/2/library/datetime.html

1
2
3
4
5
6
7
8
>>> from datetime import datetime
>>> from dateutil.parser import parse
>>> import pandas as pd

>>> war_start = '2017\/11\/27 13:03'

>>> datetime.strptime(war_start, '%Y\/%m\/%d %H:%M')
datetime.datetime(2017, 11, 27, 13, 3)

No comments:

Post a Comment