Skip to content

Commit

Permalink
python fix time divide by zero (#3838)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jun 28, 2022
1 parent a15b6b1 commit 65826c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions polars/tests/it/lazy/groupby.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use polars_core::series::ops::NullBehavior;

#[test]
fn test_filter_sort_diff_2984() -> Result<()> {
Expand Down
2 changes: 2 additions & 0 deletions py-polars/polars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def handle_projection_columns(


def _to_python_time(value: int) -> time:
if value == 0:
return time(microsecond=0)
value = value // 1_000
microsecond = value
seconds = (microsecond // 1000_000) % 60
Expand Down
4 changes: 4 additions & 0 deletions py-polars/tests/test_datelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,3 +1204,7 @@ def test_sorted_unique() -> None:
.sort("dt")
.unique()
).to_dict(False) == {"dt": [date(2015, 6, 23), date(2015, 6, 24)]}


def test_time_zero_3828() -> None:
assert pl.Series(values=[time(0)], dtype=pl.Time).to_list() == [time(0)]

0 comments on commit 65826c0

Please sign in to comment.