Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Aug 3, 2023
1 parent 27d91b2 commit b62b820
Showing 1 changed file with 3 additions and 41 deletions.
44 changes: 3 additions & 41 deletions py-polars/polars/functions/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,7 @@ def datetime_range(
interval: str | timedelta = ...,
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: Literal[False] = ...,
name: str | None = ...,
) -> Expr:
...

Expand All @@ -717,8 +714,6 @@ def datetime_range(
interval: str | timedelta = ...,
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: Literal[True],
) -> Series:
...
Expand All @@ -731,8 +726,6 @@ def datetime_range(
interval: str | timedelta = ...,
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: bool,
) -> Series | Expr:
...
Expand All @@ -744,8 +737,6 @@ def datetime_range(
interval: str | timedelta = "1d",
*,
closed: ClosedInterval = "both",
time_unit: TimeUnit | None = None,
time_zone: str | None = None,
eager: bool = False,
) -> Series | Expr:
"""
Expand All @@ -765,10 +756,6 @@ def datetime_range(
dates to valid ranges.
closed : {'both', 'left', 'right', 'none'}
Define which sides of the range are closed (inclusive).
time_unit : {None, 'ns', 'us', 'ms'}
Time unit of the resulting ``Datetime`` data type.
time_zone
Time zone of the resulting ``Datetime`` data type.
eager
Evaluate immediately and return a ``Series``.
If set to ``False`` (default), return an expression instead.
Expand All @@ -780,16 +767,10 @@ def datetime_range(
"""
interval = _parse_interval_argument(interval)
if time_unit is None and "ns" in interval:
time_unit = "ns"

start_pyexpr = parse_as_expression(start)
end_pyexpr = parse_as_expression(end)
result = wrap_expr(
plr.datetime_range(
start_pyexpr, end_pyexpr, interval, closed, time_unit, time_zone
)
)

result = wrap_expr(plr.datetime_range(start_pyexpr, end_pyexpr, interval, closed))

if eager:
return F.select(result).to_series()
Expand All @@ -804,8 +785,6 @@ def datetime_ranges(
interval: str | timedelta = ...,
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: Literal[False] = ...,
) -> Expr:
...
Expand All @@ -818,8 +797,6 @@ def datetime_ranges(
interval: str | timedelta = ...,
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: Literal[True],
) -> Series:
...
Expand All @@ -832,8 +809,6 @@ def datetime_ranges(
interval: str | timedelta = ...,
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: bool,
) -> Series | Expr:
...
Expand All @@ -845,8 +820,6 @@ def datetime_ranges(
interval: str | timedelta = "1d",
*,
closed: ClosedInterval = "both",
time_unit: TimeUnit | None = None,
time_zone: str | None = None,
eager: bool = False,
) -> Series | Expr:
"""
Expand All @@ -866,10 +839,6 @@ def datetime_ranges(
dates to valid ranges.
closed : {'both', 'left', 'right', 'none'}
Define which sides of the range are closed (inclusive).
time_unit : {None, 'ns', 'us', 'ms'}
Time unit of the resulting ``Datetime`` data type.
time_zone
Time zone of the resulting ``Datetime`` data type.
eager
Evaluate immediately and return a ``Series``.
If set to ``False`` (default), return an expression instead.
Expand All @@ -881,17 +850,10 @@ def datetime_ranges(
"""
interval = _parse_interval_argument(interval)
if time_unit is None and "ns" in interval:
time_unit = "ns"

start_pyexpr = parse_as_expression(start)
end_pyexpr = parse_as_expression(end)

result = wrap_expr(
plr.datetime_ranges(
start_pyexpr, end_pyexpr, interval, closed, time_unit, time_zone
)
)
result = wrap_expr(plr.datetime_ranges(start_pyexpr, end_pyexpr, interval, closed))

if eager:
return F.select(result).to_series()
Expand Down

0 comments on commit b62b820

Please sign in to comment.