[pandas] pandas.to_datatime()---time format conversion

Standard time format: 2012-12-21

Time conversion function: pandas.to_datatime()

# -*- coding: utf-8 -*-

# generate data
import pandas as pd 
data = {'birth':['2011/12/01','2012/12/02','2012/12/03','2012/12/04','2012/12/05']}
frame = pd.DataFrame(data)
print(frame)
"""
        birth
0  2011/12/01
1  2012/12/02
2  2012/12/03
3  2012/12/04
4  2012/12/05
"""

# Standard time format
frame['birth'] = pd.to_datetime(data['birth'])
print(frame)
"""
       birth
0 2011-12-01
1 2012-12-02
2 2012-12-03
3 2012-12-04
4 2012-12-05
"""

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325062815&siteId=291194637