This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from dateutil.parser import parse | |
a = parse('2012-11-01 02:48:30') | |
print(a) | |
import time | |
print(int(time.mktime(a.timetuple()))) | |
import pandas as pd | |
data = [['Alex','2012-11-01 02:48:30'],['Bob','2011-11-01 02:48:30'],['Clarke','2013-11-01 02:48:30']] | |
#Create a dataframe | |
df = pd.DataFrame(data,columns=['Name','EmploymentDate']) | |
#convert str to date time | |
df['Date_time1'] = pd.to_datetime(df['EmploymentDate']) | |
#convert date time to int value | |
df['date_time_int'] = df.Date_time1.astype(np.int64) | |
print(df) |
Happy Mastering DL!!!
No comments:
Post a Comment