Skip to content

Instantly share code, notes, and snippets.

@quinnj
Created July 25, 2019 03:29
Show Gist options
  • Save quinnj/0b2bc3f1ac0965a56d8afd3468c244d5 to your computer and use it in GitHub Desktop.
Save quinnj/0b2bc3f1ac0965a56d8afd3468c244d5 to your computer and use it in GitHub Desktop.
Tables.Map
rowitr = Tables.Map(x->(id=x.id, y=x.salary*2), df);
rowitr = Tables.Map(fff, df);
T = typeof(rowitr)
state = iterate(rowitr)
row, st = state
nms = Tuple(propertynames(row))
len = Base.haslength(T) ? length(rowitr) : 0
sch = Tables.Schema(nms, nothing)
columns = Tuple(Tables.EmptyVector(len) for _ = 1:length(nms))
updated = Ref{Any}(columns)
Tables.eachcolumns(Tables.add_or_widen!, sch, row, columns, 1, updated, Base.IteratorSize(rowitr))
@code_typed Tables.__buildcolumns(rowitr, st, sch, updated[], 1, updated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment