Skip to content

Commit

Permalink
fmt python
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Oct 12, 2023
1 parent 9b1443d commit 2b0e56a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
16 changes: 4 additions & 12 deletions src/polars_business/polars_business/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,22 @@ class BusinessDayTools:
def __init__(self, expr: pl.Expr):
self._expr = expr.cast(pl.Int32)


def advance_n_days(self,
n,
holidays = None
) -> pl.Expr:
def advance_n_days(self, n, holidays=None) -> pl.Expr:
# if not (isinstance(n, int) and n > 0):
# raise ValueError("only positive integers are currently supported for `n`")
if holidays is None:
return self._expr._register_plugin(
lib=lib,
symbol="advance_n_days",
is_elementwise=True,
args = [
args=[
n,
],
],
)
else:
return self._expr._register_plugin(
lib=lib,
symbol="advance_n_days",
is_elementwise=True,
args = [
n,
pl.Series([list(set(holidays))]).cast(pl.List(pl.Int32))
],
args=[n, pl.Series([list(set(holidays))]).cast(pl.List(pl.Int32))],
)

11 changes: 9 additions & 2 deletions src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
from datetime import date, datetime
import numpy as np
import holidays
hols = holidays.country_holidays('UK', years=[2020])

print(df.with_columns(pl.col('ts').business.advance_n_days(5, holidays=[date(2000, 1, 1), date(2000, 5, 1)])))
hols = holidays.country_holidays("UK", years=[2020])

print(
df.with_columns(
pl.col("ts").business.advance_n_days(
5, holidays=[date(2000, 1, 1), date(2000, 5, 1)]
)
)
)

0 comments on commit 2b0e56a

Please sign in to comment.