Created
August 20, 2015 19:43
-
-
Save tcovert/7310d9ad79c1b46d0fe0 to your computer and use it in GitHub Desktop.
DataFrames.jl non-working unstack() example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DataFrames | |
ids = rand(15000:25000, 1600) | |
ids = unique(ids) | |
ids = String[string("f",x) for x in ids] | |
keys = 1:200 | |
keys = String[string("k",x) for x in keys] | |
temp = join(DataFrame(id = ids), DataFrame(key = keys), kind = :cross) | |
keepflag = rand(size(temp,1)) | |
keepflag = keepflag .> .8 | |
temp = temp[keepflag, :] | |
temp[:v] = 1 | |
temp2 = unstack(temp, :key, :v) | |
temp3 = unstack(temp, :id, :key, :v) | |
s0 = size(unique(ids)) | |
s1 = size(unique(temp[:id])) | |
s2 = size(unique(temp2[:id])) | |
s3 = size(unique(temp3[:key])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment