Created
March 8, 2016 20:53
-
-
Save avishekrk/15fc419a9a9edc59b7ac to your computer and use it in GitHub Desktop.
Python Codes for pulling out timeseries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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