Skip to content

Commit

Permalink
support A as yearly frequency in fill_gaps (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Apr 22, 2024
1 parent d3579be commit fe357c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions nbs/preprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,17 @@
" # minutes are represented as 'm' in numpy\n",
" freq = 'm'\n",
" elif isinstance(offset.base, pd.offsets.BusinessDay):\n",
" if offset.n != 1:\n",
" if n != 1:\n",
" raise NotImplementedError('Multiple of a business day')\n",
" freq = 'D'\n",
" elif isinstance(offset.base, pd.offsets.Hour):\n",
" # hours are represented as 'h' in numpy\n",
" freq = 'h'\n",
" elif isinstance(offset.base, (pd.offsets.QuarterBegin, pd.offsets.QuarterEnd)):\n",
" n *= 3\n",
" n = 3\n",
" freq = 'M'\n",
" elif isinstance(offset.base, (pd.offsets.YearBegin, pd.offsets.YearEnd)):\n",
" freq = 'Y'\n",
" if n > 1:\n",
" freq = freq.replace(str(n), '')\n",
" try:\n",
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DEFAULT]
repo = utilsforecast
lib_name = utilsforecast
version = 0.1.6
version = 0.1.7
min_python = 3.8
license = apache2
black_formatting = True
Expand Down
2 changes: 1 addition & 1 deletion utilsforecast/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.6"
__version__ = "0.1.7"
6 changes: 4 additions & 2 deletions utilsforecast/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,17 @@ def fill_gaps(
# minutes are represented as 'm' in numpy
freq = "m"
elif isinstance(offset.base, pd.offsets.BusinessDay):
if offset.n != 1:
if n != 1:
raise NotImplementedError("Multiple of a business day")
freq = "D"
elif isinstance(offset.base, pd.offsets.Hour):
# hours are represented as 'h' in numpy
freq = "h"
elif isinstance(offset.base, (pd.offsets.QuarterBegin, pd.offsets.QuarterEnd)):
n *= 3
n = 3
freq = "M"
elif isinstance(offset.base, (pd.offsets.YearBegin, pd.offsets.YearEnd)):
freq = "Y"
if n > 1:
freq = freq.replace(str(n), "")
try:
Expand Down

0 comments on commit fe357c4

Please sign in to comment.