Skip to content

Commit 552a6f7

Browse files
committed
allow card attr-only dfs
1 parent 0391361 commit 552a6f7

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

examples/Card Attributes.ipynb

+37-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
{
3333
"cell_type": "code",
34-
"execution_count": 2,
34+
"execution_count": 12,
3535
"id": "28d31e25-56ec-4433-bc79-01a68c389549",
3636
"metadata": {},
3737
"outputs": [],
@@ -88,7 +88,7 @@
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": 3,
91+
"execution_count": 13,
9292
"id": "251a9d12-f8d5-499f-8a69-dc4a26c7d31a",
9393
"metadata": {},
9494
"outputs": [
@@ -146,7 +146,7 @@
146146
},
147147
{
148148
"cell_type": "code",
149-
"execution_count": 4,
149+
"execution_count": 14,
150150
"id": "714d3c1f-b91a-4d8f-994a-d7c897c55d25",
151151
"metadata": {},
152152
"outputs": [
@@ -194,7 +194,7 @@
194194
},
195195
{
196196
"cell_type": "code",
197-
"execution_count": 5,
197+
"execution_count": 15,
198198
"id": "e33b4eb7-c8c3-46a2-9e3b-c1b657845462",
199199
"metadata": {},
200200
"outputs": [
@@ -238,7 +238,7 @@
238238
},
239239
{
240240
"cell_type": "code",
241-
"execution_count": 6,
241+
"execution_count": 16,
242242
"id": "6f2fbdd7-a455-4be9-bd6c-d7cc0aa0eb47",
243243
"metadata": {},
244244
"outputs": [
@@ -286,7 +286,7 @@
286286
},
287287
{
288288
"cell_type": "code",
289-
"execution_count": 7,
289+
"execution_count": 17,
290290
"id": "dbf22604-af8e-43c9-ba11-42589fe1fe05",
291291
"metadata": {},
292292
"outputs": [
@@ -359,7 +359,7 @@
359359
},
360360
{
361361
"cell_type": "code",
362-
"execution_count": 8,
362+
"execution_count": 18,
363363
"id": "c883db9d-0b92-45bc-b6ad-da3e80a9949a",
364364
"metadata": {},
365365
"outputs": [
@@ -427,7 +427,7 @@
427427
},
428428
{
429429
"cell_type": "code",
430-
"execution_count": 9,
430+
"execution_count": 19,
431431
"id": "d53bab86-4031-44ba-8ead-e3e6d998ed02",
432432
"metadata": {},
433433
"outputs": [
@@ -479,7 +479,7 @@
479479
},
480480
{
481481
"cell_type": "code",
482-
"execution_count": 10,
482+
"execution_count": 20,
483483
"id": "7fe1de3d-a20d-4740-b2d5-a16a1bbe0a4f",
484484
"metadata": {},
485485
"outputs": [
@@ -530,10 +530,28 @@
530530
},
531531
{
532532
"cell_type": "code",
533-
"execution_count": null,
533+
"execution_count": 21,
534534
"id": "cbab170c-bd44-4293-b92c-22c134591b82",
535535
"metadata": {},
536-
"outputs": [],
536+
"outputs": [
537+
{
538+
"name": "stdout",
539+
"output_type": "stream",
540+
"text": [
541+
"shape: (4, 2)\n",
542+
"┌───────────────┬──────────────────────────────┐\n",
543+
"│ player_cohort ┆ greatest_deq_base_taken_rate │\n",
544+
"│ --- ┆ --- │\n",
545+
"│ str ┆ f64 │\n",
546+
"╞═══════════════╪══════════════════════════════╡\n",
547+
"│ Bottom ┆ 0.483204 │\n",
548+
"│ Middle ┆ 0.526278 │\n",
549+
"│ Other ┆ 0.483886 │\n",
550+
"│ Top ┆ 0.555001 │\n",
551+
"└───────────────┴──────────────────────────────┘\n"
552+
]
553+
}
554+
],
537555
"source": [
538556
"ext = {\n",
539557
" \"deq_base\": ColSpec(\n",
@@ -566,6 +584,14 @@
566584
" )\n",
567585
")"
568586
]
587+
},
588+
{
589+
"cell_type": "code",
590+
"execution_count": null,
591+
"id": "0a2d0e83-66c2-4008-893b-4179d79f07b7",
592+
"metadata": {},
593+
"outputs": [],
594+
"source": []
569595
}
570596
],
571597
"metadata": {

spells/draft_data.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,11 @@ def _base_agg_df(
407407
for c in cols_for_view
408408
if m.col_def_map[c].col_type in (ColType.PICK_SUM, ColType.GAME_SUM)
409409
)
410-
if sum_cols:
410+
name_sum_cols = tuple(
411+
c for c in cols_for_view if m.col_def_map[c].col_type == ColType.NAME_SUM
412+
)
413+
414+
if sum_cols or not name_sum_cols:
411415
# manifest will verify that GAME_SUM manifests do not use NAME grouping
412416
name_col_tuple = (
413417
(pl.col(ColName.PICK).alias(ColName.NAME),) if is_name_gb else ()
@@ -418,9 +422,6 @@ def _base_agg_df(
418422
grouped = sum_col_df.group_by(group_by) if group_by else sum_col_df
419423
join_dfs.append(grouped.sum().collect(streaming=use_streaming))
420424

421-
name_sum_cols = tuple(
422-
c for c in cols_for_view if m.col_def_map[c].col_type == ColType.NAME_SUM
423-
)
424425
for col in name_sum_cols:
425426
names = get_names(set_code)
426427
expr = tuple(pl.col(f"{col}_{name}").alias(name) for name in names)

spells/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def create(
208208
else:
209209
needed_views = needed_views.union({View.GAME, View.DRAFT})
210210

211-
view_cols = {v: view_cols[v] for v in needed_views}
211+
view_cols = {v: view_cols.get(v, frozenset({ColName.PICK})) for v in needed_views}
212212

213213
return Manifest(
214214
columns=cols,

0 commit comments

Comments
 (0)