Skip to content

Instantly share code, notes, and snippets.

@avishekrk
Created March 8, 2016 20:53
Show Gist options
  • Save avishekrk/15fc419a9a9edc59b7ac to your computer and use it in GitHub Desktop.
Save avishekrk/15fc419a9a9edc59b7ac to your computer and use it in GitHub Desktop.
Python Codes for pulling out timeseries
def get_ranges(ranges,delta):
"""
Get a range of numberical values
ranges: ls or numpy array
delta: sort out range of a certain interval
"""
for col in ranges:
if not('_' in col):
continue
start, end = col.split('_')
if start.isdigit():
start = int(start)
end = int(end)
delta = end - start
if delta == 500:
yield col
def sort_ranges(dficols):
"sort ranges numerically"
sort = {}
for col in dficols:
start, end = col.split('_')
start = int(start)
end = int(end)
sort[start] = col
for key in np.sort(sort.keys()):
yield sort[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment