8000 more thoughts about append_total · larray-project/larray@646e087 · GitHub
[go: up one dir, main page]

Skip to content

Commit 646e087

Browse files
committed
more thoughts about append_total
1 parent f82ba1d commit 646e087

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

larray.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,33 @@
77
# * split unit tests
88

99
# * easily add sum column for a dimension
10+
# - in all cases, we will need to define a new Axis object
11+
# - in the examples below, we suppose a.label is 'income'
12+
# - best candidates (IMO)
13+
# - a.append(age=a.sum(age)) # label is "income.sum(age)"
14+
# # ideally, it should be just "sum(age)"
15+
# # (the label on the array stays "income"
16+
# # after all, so it is redundant to add
17+
# # it here) but that is probably harder
18+
# # to get because a.sum(age).label should
19+
# # really be "income.sum(age)", it is just
20+
# # the label/tick on the new Axis that
21+
# # should not contain "income".
22+
# - a.append(age=a.sum(age).label('total')) # label is "total"
23+
# - a.append(a.sum(age), axis=age)
24+
# - a.append_total(age) # default aggregate is sum
25+
# # default label is "total"
26+
# - a.append_total(age=avg) # default aggregate is sum,
27+
# - a.append_total(age, sex=avg) # default aggregate is sum,
28+
29+
# other candidates
1030
# - a.with_total(age=np.sum)
1131
# - a.with_total(age=np.sum,np.avg) # potentially several totals
1232
# - a.append(age=a.sum(age))
1333
# - a.append(age='sum')
1434
# - a.append(age=sum)
35+
36+
# - a.append(total=a.sum(age), axis=age) # total = the name of the new label
1537
# - a.append(age='total=sum') # total = the name of the new label
1638

1739
# - the following should work already (modulo the axis name -> axis num)
@@ -20,7 +42,6 @@
2042

2143
# - np.append(a, a.sum(age), axis=age)
2244
# - a.append(a.sum(age), axis=age)
23-
# - a.append(age=a.sum(age))
2445

2546
# * check axes on arithmetics
2647
# * but special case for length 1 (to be able to do: "H + F" or "vla / belgium")

0 commit comments

Comments
 (0)
0