ENH: bad directive in to_datetime format - this uses std. strptime zone offset · Issue #13486 · pandas-dev/pandas (original) (raw)

this is really bad for me since almost all linux logfiles contain zone offset.

As far as I can see there is not workaround without parsing the timestamp twice.

Code Sample, a copy-pastable example if possible

parse common Apache access log timestamp

pd.to_datetime(['28/Jul/2006:10:22:04 -0300'], format='%d/%b/%Y:%H:%M:%S %z')

...
/usr/lib/python2.7/dist-packages/pandas/tseries/tools.pyc in _convert_listlike(arg, box, format, name)
    381                 return DatetimeIndex._simple_new(values, name=name, tz=tz)
    382             except (ValueError, TypeError):
--> 383                 raise e
    384 
    385     if arg is None:

ValueError: 'z' is a bad directive in format '%d/%b/%Y:%H:%M:%S %z'

Expected Output

should parse timestamps with zone offset

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-24-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.7
pip: 8.1.2
setuptools: 23.0.0
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
IPython: 4.2.0
sphinx: 1.3.6
patsy: 0.4.1
dateutil: 2.4.2
pytz: 2014.10
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.4.3
matplotlib: 1.5.1
openpyxl: 2.3.0
xlrd: 0.9.4
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.5.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None