Last active
March 1, 2022 01:23
-
-
Save pritamd47/e7ddc49f25ae7f1b06c201f0a8b98348 to your computer and use it in GitHub Desktop.
Clip multiple dataframes with DateTimeIndex to a time-period for which data is available in all the dataframes.
This file contains 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
# Clip time-series | |
def clip_ts(*tss): | |
mint = max([min(ts.index) for ts in tss]) | |
maxt = min([max(ts.index) for ts in tss]) | |
# clipped_tss = [ts[mint:maxt] for ts in tss] | |
clipped_tss = [ts.loc[(ts.index>=mint)&(ts.index<=maxt)] for ts in tss] | |
return clipped_tss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment