python - Pandas: Using Unix epoch timestamp as Datetime index -
my application involves dealing data (contained in csv) of following form:
epoch (number of seconds since jan 1, 1970), value 1368431149,20.3 1368431150,21.4 ..
currently read csv using numpy loadtxt method (can use read_csv pandas). series converting timestamps field follows:
timestamp_date=[datetime.datetime.fromtimestamp(timestamp_column[i]) in range(len(timestamp_column))]
i follow setting timestamp_date datetime index dataframe. tried searching @ several places see if there quicker (inbuilt) way of using these unix epoch timestamps, not find any. lot of applications make use of such timestamp terminology.
- is there inbuilt method handling such timestamp formats?
- if not, recommended way of handling these formats?
convert them datetime64[s]
:
np.array([1368431149, 1368431150]).astype('datetime64[s]') # array([2013-05-13 07:45:49, 2013-05-13 07:45:50], dtype=datetime64[s])
Comments
Post a Comment