import datetime as datetime
datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S')
produces
AttributeError Traceback (most recent call last) in () 1 import datetime as datetime ----> 2 datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S') 3 z = minidf['Dates'] 4 z
AttributeError: 'module' object has no attribute 'strptime'
my goal is to convert a pandas dataframe column whose format is still a data object
import datetime as datetime
#datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S')
z = minidf['Dates']
0 2015-05-13 23:53:00
1 2015-05-13 23:53:00
2 2015-05-13 23:33:00
3 2015-05-13 23:30:00
4 2015-05-13 23:30:00
5 2015-05-13 23:30:00
6 2015-05-13 23:30:00
7 2015-05-13 23:30:00
8 2015-05-13 23:00:00
9 2015-05-13 23:00:00
10 2015-05-13 22:58:00
Name: Dates, dtype: object
the bonus question is, i got this column using pd.read_csv
function from a larger file with more columns. Is it possible to pass parameters such that pd.read_csv
directly converts this to dtype: datetime64[ns]
format
datetime.datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S')
to refer thedatetime
class within thedatetime
module – riteshtch