wesm / pydata-book

Materials and IPython notebooks for "Python for Data Analysis" by Wes McKinney, published by O'Reilly Media
Other
22.27k stars 15.2k forks source link

Time series chapter: strftime and strptime don't use the same format codes #76

Closed jabranham closed 6 years ago

jabranham commented 6 years ago

In the part discussing converting datetime objects from strings, you say that strptime uses the same format codes as strftime, but that's not quite right:

value = '2011-01-03'
stamp = datetime.strptime(value, '%Y-%m-%d')  # works
datetime.strptime(value, '%F')  # ValueError: 'F' is a bad directive in format '%F'
datetime.strftime(stamp, '%F')  # works
wesm commented 6 years ago

Thanks for bringing this up. Could you submit an errata in the O'Reilly portal? http://shop.oreilly.com/product/0636920050896.do

jabranham commented 6 years ago

Done

wesm commented 6 years ago

thank you!