dycw-utilities 0.165.2__py3-none-any.whl → 0.165.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dycw_utilities-0.165.2.dist-info → dycw_utilities-0.165.3.dist-info}/METADATA +1 -1
- {dycw_utilities-0.165.2.dist-info → dycw_utilities-0.165.3.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/polars.py +30 -0
- {dycw_utilities-0.165.2.dist-info → dycw_utilities-0.165.3.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.165.2.dist-info → dycw_utilities-0.165.3.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.165.2.dist-info → dycw_utilities-0.165.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=dGyOX1Z3m0mhIPCR1cqAXlybAWUxvEasnTNSAfT9Fh8,60
|
2
2
|
utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
|
3
3
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
4
4
|
utilities/asyncio.py,sha256=PUedzQ5deqlSECQ33sam9cRzI9TnygHz3FdOqWJWPTM,15288
|
@@ -45,7 +45,7 @@ utilities/parse.py,sha256=JcJn5yXKhIWXBCwgBdPsyu7Hvcuw6kyEdqvaebCaI9k,17951
|
|
45
45
|
utilities/pathlib.py,sha256=qGuU8XPmdgGpy8tOMUgelfXx3kxI8h9IaV3TI_06QGE,8428
|
46
46
|
utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
47
47
|
utilities/platform.py,sha256=pTn7gw6N4T6LdKrf0virwarof_mze9WtoQlrGMzhGVI,2798
|
48
|
-
utilities/polars.py,sha256=
|
48
|
+
utilities/polars.py,sha256=6_k8cU7LePQ942Qfqe5l_tR8ND0M0bLlpnaMvDbRCM8,81754
|
49
49
|
utilities/polars_ols.py,sha256=LNTFNLPuYW7fcAHymlbnams_DhitToblYvib3mhKbwI,5615
|
50
50
|
utilities/postgres.py,sha256=ynCTTaF-bVEOSW-KEAR-dlLh_hYjeVVjm__-4pEU8Zk,12269
|
51
51
|
utilities/pottery.py,sha256=ggMN72Y7wx7Js8VN6eyNyodpm8TIYqZHGghkDPXIVWk,3949
|
@@ -88,8 +88,8 @@ utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
|
|
88
88
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
89
89
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
90
90
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
91
|
-
dycw_utilities-0.165.
|
92
|
-
dycw_utilities-0.165.
|
93
|
-
dycw_utilities-0.165.
|
94
|
-
dycw_utilities-0.165.
|
95
|
-
dycw_utilities-0.165.
|
91
|
+
dycw_utilities-0.165.3.dist-info/METADATA,sha256=pkTtRCmg_YK5SUclEGBHKWThH6nFfAdR3vn_EJZjGO8,1696
|
92
|
+
dycw_utilities-0.165.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
93
|
+
dycw_utilities-0.165.3.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
94
|
+
dycw_utilities-0.165.3.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
95
|
+
dycw_utilities-0.165.3.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/polars.py
CHANGED
@@ -105,6 +105,7 @@ from utilities.whenever import (
|
|
105
105
|
from utilities.zoneinfo import UTC, to_time_zone_name
|
106
106
|
|
107
107
|
if TYPE_CHECKING:
|
108
|
+
import datetime as dt
|
108
109
|
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
109
110
|
from collections.abc import Set as AbstractSet
|
110
111
|
|
@@ -2460,6 +2461,34 @@ class RoundToFloatError(Exception):
|
|
2460
2461
|
##
|
2461
2462
|
|
2462
2463
|
|
2464
|
+
def search_period(
|
2465
|
+
series: Series,
|
2466
|
+
date_time: ZonedDateTime,
|
2467
|
+
/,
|
2468
|
+
*,
|
2469
|
+
start_or_end: Literal["start", "end"] = "end",
|
2470
|
+
) -> int | None:
|
2471
|
+
"""Search a series of periods for the one containing a given date-time."""
|
2472
|
+
start, end = [series.struct[k] for k in ["start", "end"]]
|
2473
|
+
py_date_time = date_time.py_datetime()
|
2474
|
+
match start_or_end:
|
2475
|
+
case "start":
|
2476
|
+
index = end.search_sorted(py_date_time, side="right")
|
2477
|
+
if index >= len(series):
|
2478
|
+
return None
|
2479
|
+
item: dt.datetime = series[index]["start"]
|
2480
|
+
return index if py_date_time >= item else None
|
2481
|
+
case "end":
|
2482
|
+
index = end.search_sorted(py_date_time, side="left")
|
2483
|
+
if index >= len(series):
|
2484
|
+
return None
|
2485
|
+
item: dt.datetime = series[index]["start"]
|
2486
|
+
return index if py_date_time > item else None
|
2487
|
+
|
2488
|
+
|
2489
|
+
##
|
2490
|
+
|
2491
|
+
|
2463
2492
|
def select_exact(
|
2464
2493
|
df: DataFrame, /, *columns: IntoExprColumn, drop: MaybeIterable[str] | None = None
|
2465
2494
|
) -> DataFrame:
|
@@ -2750,6 +2779,7 @@ __all__ = [
|
|
2750
2779
|
"read_series",
|
2751
2780
|
"replace_time_zone",
|
2752
2781
|
"round_to_float",
|
2782
|
+
"search_period",
|
2753
2783
|
"select_exact",
|
2754
2784
|
"serialize_dataframe",
|
2755
2785
|
"set_first_row_as_columns",
|
File without changes
|
File without changes
|
File without changes
|