Skip to content

Instantly share code, notes, and snippets.

@seumasmorrison
Created August 17, 2012 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seumasmorrison/3377772 to your computer and use it in GitHub Desktop.
Save seumasmorrison/3377772 to your computer and use it in GitHub Desktop.
Sample input data and python code for Pandas time-series problem
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment