i trying use pd.series replicate time column, gave me different time, why , how can use pd.series function replicate time column in pandas?
import numpy np import pandas pd pandas import series, dataframe, panel # data data = pd.read_csv('somedata.csv', header=0, encoding='utf-8', low_memory=false) df = dataframe(data) df = df.sort(['time'], ascending=true) # sort time # create new df column using df.time df['time2'] = pd.series(pd.to_datetime(date) date in df['time']) df['time3'] = df['time'] print df.head() time 567 1/1/2015 0:12 566 1/1/2015 0:14 565 1/1/2015 0:28 564 1/1/2015 0:30 563 1/1/2015 0:42 time2 567 2015-01-12 21:43:00 566 2015-01-12 21:43:00 565 2015-01-12 21:43:00 564 2015-01-12 21:43:00 563 2015-01-12 21:43:00 time3 567 1/1/2015 0:12 566 1/1/2015 0:14 565 1/1/2015 0:28 564 1/1/2015 0:30 563 1/1/2015 0:42
Comments
Post a Comment