简体   繁体   中英

Converting Timestamp('YYYY-MM-DD HH:MM:SS') to simple datetime format

When I import data from excel in python, the dates there appear in the Timestamp format i mentioned in the title, which makes it very difficult to match dates(I need to match a few specific dates in the entire list i imported and do some calculations). So, is there a way to convert this into datetime format so that i can apply functions like timedelta etc. (or) is there a way of doing what I need without datetime. Any help would be extremely helpful. Thanks!!

Assuming the imported date is a Numpy timestamp, how about:

import datetime as dt

df['date_format'] = [ts.astype(dt.datetime).date() for ts in df['imported_date]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM