import datetime
string = "19 Nov 2015 18:45:00.000"
date = datetime.datetime.strptime(string, "%d %b %Y %H:%M:%S.%f")
print date
#OR you can do
from dateutil.parser import parse
date = parse('19 Nov 2015 18:45:00.000')
# To access the desired individual Variables separately (year,month,day,hour, min,sec):
date.year
date.month
date.day
date.hour
date.minute
date.second
#OR
print date.year
print date.month
print date.day
print date.hour
print date.minute
print date.second
import pandas as pd
df = pd.DataFrame({'datetime':pd.date_range('2020-01-01 07:10',periods=6)})
print("DataFrame is:
", df)
df['date'] = pd.to_datetime(df['datetime']).dt.date
df['time'] = pd.to_datetime(df['datetime']).dt.time
print("Date-time-hour-minutes :
", df)
for d in df['datetime']:
df['date'] = d.date()
df['time'] = d.time()