Note

Pandas (21) 본문

Pandas

Pandas (21)

알 수 없는 사용자 2022. 8. 12. 11:58
728x90

How to convert a series of date-strings to a timeseries?

# Input
ser = pd.Series(['01 Jan 2010', '02-02-2011', '20120303', '2013/04/04', '2014-05-05', '2015-06-06T12:20'])

# 1
from dateutil.parser import parse
ser.map(lambda x: parse(x))

# 2
pd.to_datetime(ser)

# output
0   2010-01-01 00:00:00
1   2011-02-02 00:00:00
2   2012-03-03 00:00:00
3   2013-04-04 00:00:00
4   2014-05-05 00:00:00
5   2015-06-06 12:20:00
dtype: datetime64[ns]

'Pandas' 카테고리의 다른 글

Pandas (23)  (0) 2022.08.14
Pandas (22)  (0) 2022.08.13
Pandas (20)  (0) 2022.08.11
Pandas (19)  (0) 2022.08.10
Pandas (18)  (0) 2022.08.09
Comments