dycw-utilities 0.166.15__py3-none-any.whl → 0.166.16__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.166.15.dist-info → dycw_utilities-0.166.16.dist-info}/METADATA +1 -1
- {dycw_utilities-0.166.15.dist-info → dycw_utilities-0.166.16.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/polars.py +137 -0
- {dycw_utilities-0.166.15.dist-info → dycw_utilities-0.166.16.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.166.15.dist-info → dycw_utilities-0.166.16.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.166.15.dist-info → dycw_utilities-0.166.16.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=FemsKd9UtEJaP-BgHzGaJoLRpH-_mhv6Y7fl8XXOKCY,61
|
2
2
|
utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
|
3
3
|
utilities/altair.py,sha256=nHdpWt8ZwdUwRQN970MvHd5bRWokNqzHcZQEdSHKRuE,9033
|
4
4
|
utilities/asyncio.py,sha256=PUedzQ5deqlSECQ33sam9cRzI9TnygHz3FdOqWJWPTM,15288
|
@@ -46,7 +46,7 @@ utilities/parse.py,sha256=JcJn5yXKhIWXBCwgBdPsyu7Hvcuw6kyEdqvaebCaI9k,17951
|
|
46
46
|
utilities/pathlib.py,sha256=X6pHmfT3hnBGysdTr73uHsNaBEgKviZhk7aGWvEXDXo,8912
|
47
47
|
utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
48
48
|
utilities/platform.py,sha256=pTn7gw6N4T6LdKrf0virwarof_mze9WtoQlrGMzhGVI,2798
|
49
|
-
utilities/polars.py,sha256=
|
49
|
+
utilities/polars.py,sha256=qsiYY9p_41fORGnc7HNkA4zhlsycK7sgD74xuigMDAc,87466
|
50
50
|
utilities/polars_ols.py,sha256=LNTFNLPuYW7fcAHymlbnams_DhitToblYvib3mhKbwI,5615
|
51
51
|
utilities/postgres.py,sha256=ynCTTaF-bVEOSW-KEAR-dlLh_hYjeVVjm__-4pEU8Zk,12269
|
52
52
|
utilities/pottery.py,sha256=ggMN72Y7wx7Js8VN6eyNyodpm8TIYqZHGghkDPXIVWk,3949
|
@@ -91,8 +91,8 @@ utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
|
|
91
91
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
92
92
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
93
93
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
94
|
-
dycw_utilities-0.166.
|
95
|
-
dycw_utilities-0.166.
|
96
|
-
dycw_utilities-0.166.
|
97
|
-
dycw_utilities-0.166.
|
98
|
-
dycw_utilities-0.166.
|
94
|
+
dycw_utilities-0.166.16.dist-info/METADATA,sha256=mRIYx_yS0XbJdgF91-6wfLFf0a8T4bRtJC_v3cLoFO4,1702
|
95
|
+
dycw_utilities-0.166.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
96
|
+
dycw_utilities-0.166.16.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
97
|
+
dycw_utilities-0.166.16.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
98
|
+
dycw_utilities-0.166.16.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/polars.py
CHANGED
@@ -70,6 +70,7 @@ from utilities.iterables import (
|
|
70
70
|
check_supermapping,
|
71
71
|
is_iterable_not_str,
|
72
72
|
one,
|
73
|
+
resolve_include_and_exclude,
|
73
74
|
)
|
74
75
|
from utilities.json import write_formatted_json
|
75
76
|
from utilities.math import (
|
@@ -1269,6 +1270,111 @@ def expr_to_series(expr: Expr, /) -> Series:
|
|
1269
1270
|
##
|
1270
1271
|
|
1271
1272
|
|
1273
|
+
@overload
|
1274
|
+
def filter_date(
|
1275
|
+
column: ExprLike = "datetime",
|
1276
|
+
/,
|
1277
|
+
*,
|
1278
|
+
time_zone: ZoneInfo | None = None,
|
1279
|
+
include: MaybeIterable[whenever.Date] | None = None,
|
1280
|
+
exclude: MaybeIterable[whenever.Date] | None = None,
|
1281
|
+
) -> Expr: ...
|
1282
|
+
@overload
|
1283
|
+
def filter_date(
|
1284
|
+
column: Series,
|
1285
|
+
/,
|
1286
|
+
*,
|
1287
|
+
time_zone: ZoneInfo | None = None,
|
1288
|
+
include: MaybeIterable[whenever.Date] | None = None,
|
1289
|
+
exclude: MaybeIterable[whenever.Date] | None = None,
|
1290
|
+
) -> Series: ...
|
1291
|
+
@overload
|
1292
|
+
def filter_date(
|
1293
|
+
column: IntoExprColumn = "datetime",
|
1294
|
+
/,
|
1295
|
+
*,
|
1296
|
+
time_zone: ZoneInfo | None = None,
|
1297
|
+
include: MaybeIterable[whenever.Date] | None = None,
|
1298
|
+
exclude: MaybeIterable[whenever.Date] | None = None,
|
1299
|
+
) -> ExprOrSeries: ...
|
1300
|
+
def filter_date(
|
1301
|
+
column: IntoExprColumn = "datetime",
|
1302
|
+
/,
|
1303
|
+
*,
|
1304
|
+
time_zone: ZoneInfo | None = None,
|
1305
|
+
include: MaybeIterable[whenever.Date] | None = None,
|
1306
|
+
exclude: MaybeIterable[whenever.Date] | None = None,
|
1307
|
+
) -> ExprOrSeries:
|
1308
|
+
"""Compute the filter based on a set of dates."""
|
1309
|
+
column = ensure_expr_or_series(column)
|
1310
|
+
if time_zone is not None:
|
1311
|
+
column = column.dt.convert_time_zone(time_zone.key)
|
1312
|
+
keep = true_like(column)
|
1313
|
+
date = column.dt.date()
|
1314
|
+
include, exclude = resolve_include_and_exclude(include=include, exclude=exclude)
|
1315
|
+
if include is not None:
|
1316
|
+
keep &= date.is_in([d.py_date() for d in include])
|
1317
|
+
if exclude is not None:
|
1318
|
+
keep &= ~date.is_in([d.py_date() for d in exclude])
|
1319
|
+
return try_reify_expr(keep, column)
|
1320
|
+
|
1321
|
+
|
1322
|
+
@overload
|
1323
|
+
def filter_time(
|
1324
|
+
column: ExprLike = "datetime",
|
1325
|
+
/,
|
1326
|
+
*,
|
1327
|
+
time_zone: ZoneInfo | None = None,
|
1328
|
+
include: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1329
|
+
exclude: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1330
|
+
) -> Expr: ...
|
1331
|
+
@overload
|
1332
|
+
def filter_time(
|
1333
|
+
column: Series,
|
1334
|
+
/,
|
1335
|
+
*,
|
1336
|
+
time_zone: ZoneInfo | None = None,
|
1337
|
+
include: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1338
|
+
exclude: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1339
|
+
) -> Series: ...
|
1340
|
+
@overload
|
1341
|
+
def filter_time(
|
1342
|
+
column: IntoExprColumn = "datetime",
|
1343
|
+
/,
|
1344
|
+
*,
|
1345
|
+
time_zone: ZoneInfo | None = None,
|
1346
|
+
include: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1347
|
+
exclude: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1348
|
+
) -> ExprOrSeries: ...
|
1349
|
+
def filter_time(
|
1350
|
+
column: IntoExprColumn = "datetime",
|
1351
|
+
/,
|
1352
|
+
*,
|
1353
|
+
time_zone: ZoneInfo | None = None,
|
1354
|
+
include: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1355
|
+
exclude: MaybeIterable[tuple[whenever.Time, whenever.Time]] | None = None,
|
1356
|
+
) -> ExprOrSeries:
|
1357
|
+
"""Compute the filter based on a set of times."""
|
1358
|
+
column = ensure_expr_or_series(column)
|
1359
|
+
if time_zone is not None:
|
1360
|
+
column = column.dt.convert_time_zone(time_zone.key)
|
1361
|
+
keep = true_like(column)
|
1362
|
+
time = column.dt.time()
|
1363
|
+
include, exclude = resolve_include_and_exclude(include=include, exclude=exclude)
|
1364
|
+
if include is not None:
|
1365
|
+
keep &= any_horizontal(
|
1366
|
+
time.is_between(s.py_time(), e.py_time()) for s, e in include
|
1367
|
+
)
|
1368
|
+
if exclude is not None:
|
1369
|
+
keep &= ~any_horizontal(
|
1370
|
+
time.is_between(s.py_time(), e.py_time()) for s, e in exclude
|
1371
|
+
)
|
1372
|
+
return try_reify_expr(keep, column)
|
1373
|
+
|
1374
|
+
|
1375
|
+
##
|
1376
|
+
|
1377
|
+
|
1272
1378
|
@overload
|
1273
1379
|
def finite_ewm_mean(
|
1274
1380
|
column: ExprLike,
|
@@ -2643,6 +2749,33 @@ def to_not_false(column: IntoExprColumn, /) -> ExprOrSeries:
|
|
2643
2749
|
##
|
2644
2750
|
|
2645
2751
|
|
2752
|
+
@overload
|
2753
|
+
def true_like(column: ExprLike, /) -> Expr: ...
|
2754
|
+
@overload
|
2755
|
+
def true_like(column: Series, /) -> Series: ...
|
2756
|
+
@overload
|
2757
|
+
def true_like(column: IntoExprColumn, /) -> ExprOrSeries: ...
|
2758
|
+
def true_like(column: IntoExprColumn, /) -> ExprOrSeries:
|
2759
|
+
"""Compute a column of `True` values."""
|
2760
|
+
column = ensure_expr_or_series(column)
|
2761
|
+
return column.is_null() | column.is_not_null()
|
2762
|
+
|
2763
|
+
|
2764
|
+
@overload
|
2765
|
+
def false_like(column: ExprLike, /) -> Expr: ...
|
2766
|
+
@overload
|
2767
|
+
def false_like(column: Series, /) -> Series: ...
|
2768
|
+
@overload
|
2769
|
+
def false_like(column: IntoExprColumn, /) -> ExprOrSeries: ...
|
2770
|
+
def false_like(column: IntoExprColumn, /) -> ExprOrSeries:
|
2771
|
+
"""Compute a column of `False` values."""
|
2772
|
+
column = ensure_expr_or_series(column)
|
2773
|
+
return column.is_null() & column.is_not_null()
|
2774
|
+
|
2775
|
+
|
2776
|
+
##
|
2777
|
+
|
2778
|
+
|
2646
2779
|
def try_reify_expr(
|
2647
2780
|
expr: IntoExprColumn, /, *exprs: IntoExprColumn, **named_exprs: IntoExprColumn
|
2648
2781
|
) -> ExprOrSeries:
|
@@ -2798,6 +2931,9 @@ __all__ = [
|
|
2798
2931
|
"ensure_expr_or_series",
|
2799
2932
|
"ensure_expr_or_series_many",
|
2800
2933
|
"expr_to_series",
|
2934
|
+
"false_like",
|
2935
|
+
"filter_date",
|
2936
|
+
"filter_time",
|
2801
2937
|
"finite_ewm_mean",
|
2802
2938
|
"first_true_horizontal",
|
2803
2939
|
"get_data_type_or_series_time_zone",
|
@@ -2838,6 +2974,7 @@ __all__ = [
|
|
2838
2974
|
"to_not_true",
|
2839
2975
|
"to_true",
|
2840
2976
|
"touch",
|
2977
|
+
"true_like",
|
2841
2978
|
"try_reify_expr",
|
2842
2979
|
"uniform",
|
2843
2980
|
"unique_element",
|
File without changes
|
File without changes
|
File without changes
|