Skip to content

Commit

Permalink
Migrate to new DataFrames
Browse files Browse the repository at this point in the history
  • Loading branch information
aaowens committed Jun 21, 2020
1 parent e191260 commit b81ca82
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/construct_alldata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function construct_alldata(famdatas, inddata; codemissings = true)
df[!, :ishead] .= ishead
end
end

allinds = DataFrame()
for y_nx in eachindex(years)
di = newdatas_ind[y_nx]
Expand All @@ -127,12 +126,13 @@ function construct_alldata(famdatas, inddata; codemissings = true)
dj_heads = @where(di, in.(:rel_head_ind, (1, 10) |> Set |> Ref))
dj_spouses = @where(di, in.(:rel_head_ind, (2, 20, 22) |> Set |> Ref))
djall = vcat(dj_heads, dj_spouses)
famids = by(djall, [:id_family, :year], (:id_ind,) => x -> (famid = famid(x.id_ind),))
#famids = by(djall, [:id_family, :year], (:id_ind,) => x -> (famid = famid(x.id_ind),))
famids = combine(groupby(djall, [:id_family, :year]), AsTable(:id_ind) => (x -> famid(x.id_ind) => :famid))
# join the heads with the head family file
hi = join(dj_heads, newdatas2.headdata[y_nx], on = [:id_family, :year])
si = join(dj_spouses, newdatas2.spousedata[y_nx], on = [:id_family, :year])
hi = join(hi, famids, on = [:id_family, :year])
si = join(si, famids, on = [:id_family, :year])
hi = innerjoin(dj_heads, newdatas2.headdata[y_nx], on = [:id_family, :year])
si = innerjoin(dj_spouses, newdatas2.spousedata[y_nx], on = [:id_family, :year])
hi = innerjoin(hi, famids, on = [:id_family, :year])
si = innerjoin(si, famids, on = [:id_family, :year])
allinds = vcat(allinds, hi, cols = :union)
allinds = vcat(allinds, si, cols = :union)
end
Expand Down

0 comments on commit b81ca82

Please sign in to comment.