Created
July 4, 2020 13:36
-
-
Save Tdual/44d3c6ab11c30e951f12f24ca6ed2c39 to your computer and use it in GitHub Desktop.
infer_freq
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
def infer_freq(self, pd_series): | |
d = { | |
"A": "year", | |
"M": "month", | |
"W": "week", | |
"D": "day", | |
"H": "hour", | |
"T": "min", | |
"S": "sec", | |
"L": "millisec", | |
"U": "microsec", | |
"N": "nanosec" | |
} # ref: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html | |
rep = pd.DatetimeIndex(pd_series).inferred_freq | |
unit = re.sub("\d", "", rep) | |
freq = d.get(unit) | |
return freq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment