public
Last active

Sample input data and python code for Pandas time-series problem

  • Download Gist
pandas-example.py
Python
1 2 3 4 5 6 7 8 9 10 11
import pandas as pd
 
data_frame = pd.io.parsers.read_csv('time-series.csv',index_col = 0, names=['index','heave'])
_max = [[5, 259.0]]
indexes = [x[0] for x in _max ]
index = data_frame.index
timestamps = [index[z] for z in indexes]
#['2011-12-30 00:00:04']
print data_frame.ix[timestamps]
# heave
#2011-12-30 00:00:04 259
time-series.csv
1 2 3 4 5 6 7 8 9 10 11
2011-12-30 00:00:00,-310.0
2011-12-30 00:00:01,-238.0
2011-12-30 00:00:01.500000,-114.0
2011-12-30 00:00:02.500000,60.0
2011-12-30 00:00:03,185.0
2011-12-30 00:00:04,259.0
2011-12-30 00:00:04.500000,231.0
2011-12-30 00:00:05.500000,139.0
2011-12-30 00:00:06.500000,55.0
2011-12-30 00:00:07,-49.0
2011-12-30 00:00:08,-144.0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.