Created
May 10, 2022 16:40
-
-
Save tommylees112/13cf768a3e486b851eca5afb7aee5ea8 to your computer and use it in GitHub Desktop.
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
import calplot | |
cfg_date_ranges = { "test_date_ranges": [ | |
[ | |
"2011-01-01", | |
"2011-12-31" | |
], | |
[ | |
"2020-01-01", | |
"2020-12-31" | |
] | |
], | |
"train_date_ranges": [ | |
[ | |
"2010-01-01", | |
"2010-12-31" | |
], | |
[ | |
"2012-01-01", | |
"2012-12-31" | |
], | |
[ | |
"2014-01-01", | |
"2017-12-31" | |
], | |
[ | |
"2019-01-01", | |
"2019-12-31" | |
], | |
[ | |
"2021-01-01", | |
"2021-12-31" | |
] | |
], | |
"val_date_ranges": [ | |
[ | |
"2013-01-01", | |
"2013-12-31" | |
], | |
[ | |
"2018-01-01", | |
"2018-12-31" | |
] | |
] | |
} | |
all_vars = [] | |
for key in cfg_date_ranges.keys(): | |
dr = np.concatenate([ | |
pd.date_range(dr[0], dr[1]) for dr in cfg_date_ranges[key] | |
]) | |
_df = pd.DataFrame({"date": dr, "split": [key.split("_")[0] for _ in dr]}) | |
all_vars.append(_df) | |
df = pd.concat(all_vars).sort_values("date").astype({"split": "category"}) | |
df = df.set_index("date") | |
df["split_code"] = df.split.cat.codes | |
calplot.calplot(df["split_code"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't actually know how to control the colouring, the plot I created I did manually