dycw-utilities 0.159.7__py3-none-any.whl → 0.160.0__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.159.7.dist-info → dycw_utilities-0.160.0.dist-info}/METADATA +1 -1
- {dycw_utilities-0.159.7.dist-info → dycw_utilities-0.160.0.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/polars.py +37 -32
- {dycw_utilities-0.159.7.dist-info → dycw_utilities-0.160.0.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.159.7.dist-info → dycw_utilities-0.160.0.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.159.7.dist-info → dycw_utilities-0.160.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=KzM9quB3tnVvjnkbcK8xcoFUxydORZMj9PxkQWDPRDo,60
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
3
|
utilities/asyncio.py,sha256=PUedzQ5deqlSECQ33sam9cRzI9TnygHz3FdOqWJWPTM,15288
|
4
4
|
utilities/atomicwrites.py,sha256=tPo6r-Rypd9u99u66B9z86YBPpnLrlHtwox_8Z7T34Y,5790
|
@@ -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=z1A4Uqqbccu1rSYmymMq6Ku5mLxEFpRhPGgoQ41WLyA,79912
|
49
49
|
utilities/polars_ols.py,sha256=Uc9V5kvlWZ5cU93lKZ-cfAKdVFFw81tqwLW9PxtUvMs,5618
|
50
50
|
utilities/postgres.py,sha256=ynCTTaF-bVEOSW-KEAR-dlLh_hYjeVVjm__-4pEU8Zk,12269
|
51
51
|
utilities/pottery.py,sha256=ggMN72Y7wx7Js8VN6eyNyodpm8TIYqZHGghkDPXIVWk,3949
|
@@ -87,8 +87,8 @@ utilities/zoneinfo.py,sha256=FBMcUQ4662Aq8SsuCL1OAhDQiyANmVjtb-C30DRrWoE,1966
|
|
87
87
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
88
88
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
89
89
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
90
|
-
dycw_utilities-0.
|
91
|
-
dycw_utilities-0.
|
92
|
-
dycw_utilities-0.
|
93
|
-
dycw_utilities-0.
|
94
|
-
dycw_utilities-0.
|
90
|
+
dycw_utilities-0.160.0.dist-info/METADATA,sha256=uNm9eVdsStvpIIDOUkcqxeyAqHAdEDZTHTQ_4FJt8EQ,1643
|
91
|
+
dycw_utilities-0.160.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
92
|
+
dycw_utilities-0.160.0.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
93
|
+
dycw_utilities-0.160.0.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
94
|
+
dycw_utilities-0.160.0.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/polars.py
CHANGED
@@ -1325,18 +1325,6 @@ class _FiniteEWMWeightsError(Exception):
|
|
1325
1325
|
##
|
1326
1326
|
|
1327
1327
|
|
1328
|
-
@overload
|
1329
|
-
def first_true_horizontal(column: Series, /) -> Series: ...
|
1330
|
-
@overload
|
1331
|
-
def first_true_horizontal(column1: Series, column2: Series, /) -> Series: ...
|
1332
|
-
@overload
|
1333
|
-
def first_true_horizontal(
|
1334
|
-
column1: Series, column2: Series, column3: Series, /
|
1335
|
-
) -> Series: ...
|
1336
|
-
@overload
|
1337
|
-
def first_true_horizontal(
|
1338
|
-
column1: Series, column2: Series, column3: Series, column4: Series, /
|
1339
|
-
) -> Series: ...
|
1340
1328
|
@overload
|
1341
1329
|
def first_true_horizontal(*columns: Series) -> Series: ...
|
1342
1330
|
@overload
|
@@ -1931,27 +1919,17 @@ def nan_sum_agg(column: str | Expr, /, *, dtype: PolarsDataType | None = None) -
|
|
1931
1919
|
##
|
1932
1920
|
|
1933
1921
|
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1922
|
+
@overload
|
1923
|
+
def nan_sum_horizonal(*columns: Series) -> Series: ...
|
1924
|
+
@overload
|
1925
|
+
def nan_sum_horizonal(*columns: IntoExprColumn) -> ExprOrSeries: ...
|
1926
|
+
def nan_sum_horizonal(*columns: IntoExprColumn) -> ExprOrSeries:
|
1937
1927
|
"""Nan sum across columns."""
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1928
|
+
columns2 = ensure_expr_or_series_many(*columns)
|
1929
|
+
expr = when(any_horizontal(*(c.is_not_null() for c in columns2))).then(
|
1930
|
+
sum_horizontal(*columns2)
|
1941
1931
|
)
|
1942
|
-
|
1943
|
-
def func(x: Expr, y: Expr, /) -> Expr:
|
1944
|
-
return (
|
1945
|
-
when(x.is_not_null() & y.is_not_null())
|
1946
|
-
.then(x + y)
|
1947
|
-
.when(x.is_not_null() & y.is_null())
|
1948
|
-
.then(x)
|
1949
|
-
.when(x.is_null() & y.is_not_null())
|
1950
|
-
.then(y)
|
1951
|
-
.otherwise(lit(None, dtype=dtype))
|
1952
|
-
)
|
1953
|
-
|
1954
|
-
return reduce(func, all_exprs)
|
1932
|
+
return try_reify_expr(expr, *columns2)
|
1955
1933
|
|
1956
1934
|
|
1957
1935
|
##
|
@@ -2446,6 +2424,31 @@ class RoundToFloatError(Exception):
|
|
2446
2424
|
##
|
2447
2425
|
|
2448
2426
|
|
2427
|
+
def select_exact(
|
2428
|
+
df: DataFrame, /, *columns: IntoExprColumn, drop: MaybeIterable[str] | None = None
|
2429
|
+
) -> DataFrame:
|
2430
|
+
"""Select an exact set of columns from a DataFrame."""
|
2431
|
+
names = [get_expr_name(df, c) for c in columns]
|
2432
|
+
drop = set() if drop is None else set(always_iterable(drop))
|
2433
|
+
union = set(names) | drop
|
2434
|
+
extra = [c for c in df.columns if c not in union]
|
2435
|
+
if len(extra) >= 1:
|
2436
|
+
raise SelectExactError(columns=extra)
|
2437
|
+
return df.select(*columns)
|
2438
|
+
|
2439
|
+
|
2440
|
+
@dataclass(kw_only=True, slots=True)
|
2441
|
+
class SelectExactError(Exception):
|
2442
|
+
columns: list[str]
|
2443
|
+
|
2444
|
+
@override
|
2445
|
+
def __str__(self) -> str:
|
2446
|
+
return f"All columns must be selected; got {get_repr(self.columns)} remaining"
|
2447
|
+
|
2448
|
+
|
2449
|
+
##
|
2450
|
+
|
2451
|
+
|
2449
2452
|
def set_first_row_as_columns(df: DataFrame, /) -> DataFrame:
|
2450
2453
|
"""Set the first row of a DataFrame as its columns."""
|
2451
2454
|
try:
|
@@ -2654,6 +2657,7 @@ __all__ = [
|
|
2654
2657
|
"OneColumnError",
|
2655
2658
|
"OneColumnNonUniqueError",
|
2656
2659
|
"RoundToFloatError",
|
2660
|
+
"SelectExactError",
|
2657
2661
|
"SetFirstRowAsColumnsError",
|
2658
2662
|
"TimePeriodDType",
|
2659
2663
|
"acf",
|
@@ -2698,7 +2702,7 @@ __all__ = [
|
|
2698
2702
|
"join_into_periods",
|
2699
2703
|
"map_over_columns",
|
2700
2704
|
"nan_sum_agg",
|
2701
|
-
"
|
2705
|
+
"nan_sum_horizonal",
|
2702
2706
|
"normal",
|
2703
2707
|
"number_of_decimals",
|
2704
2708
|
"offset_datetime",
|
@@ -2709,6 +2713,7 @@ __all__ = [
|
|
2709
2713
|
"read_series",
|
2710
2714
|
"replace_time_zone",
|
2711
2715
|
"round_to_float",
|
2716
|
+
"select_exact",
|
2712
2717
|
"serialize_dataframe",
|
2713
2718
|
"set_first_row_as_columns",
|
2714
2719
|
"struct_dtype",
|
File without changes
|
File without changes
|
File without changes
|