Skip to content

Commit

Permalink
Simplify min / max access
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-lacroix authored and ritchie46 committed Oct 31, 2021
1 parent bc9e7da commit 6e19c95
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions py-polars/polars/eager/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import os
import typing as tp
from datetime import datetime, timedelta
from datetime import timedelta
from io import BytesIO, StringIO
from pathlib import Path
from typing import (
Expand Down Expand Up @@ -1916,13 +1916,10 @@ def upsample(
f"Column {by} should be of type datetime. Got {self[by].dtype}"
)
bounds = self.select(
[
pl.col(by).min().alias("low").dt.to_python_datetime(),
pl.col(by).max().alias("high").dt.to_python_datetime(),
]
[pl.col(by).min().alias("low"), pl.col(by).max().alias("high")]
)
low: datetime = bounds[0, "low"]
high: datetime = bounds[0, "high"]
low = bounds["low"].dt[0]
high = bounds["high"].dt[0]
upsampled = pl.date_range(low, high, interval, name=by)
return pl.DataFrame(upsampled).join(self, on=by, how="left")

Expand Down

0 comments on commit 6e19c95

Please sign in to comment.