1. 程式人生 > >【pandas】pandas.to_datatime()---時間格式轉換

【pandas】pandas.to_datatime()---時間格式轉換

ID top -- AS style port adding int 2-2

標準時間格式:2012-12-21

時間轉換函數:pandas.to_datatime()

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

# 生成數據
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
"""

# 標準時間格式
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 """

【pandas】pandas.to_datatime()---時間格式轉換