Skip to content

Commit

Permalink
Merge pull request #1 from tshort/DataPlaying
Browse files Browse the repository at this point in the history
Fix for SubDataFrame ref and change to col slices for DataFrame
  • Loading branch information
HarlanH committed Jun 22, 2012
2 parents 122637c + 86a795e commit 183dbfa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions extras/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,10 @@ ref(df::DataFrame, rs::Vector{Int}, rng::Range1) = DataFrame({x[rs] for x in df.
df.colnames[rng])
ref(df::DataFrame, rs::Vector{Int}, cs::Vector{Bool}) = df[cs][rs,:] # slow way
ref{CT}(df::DataFrame{CT}, rs::Vector{Int}, cs::Vector{CT}) = df[cs][rs,:] # slow way
ref(df::DataFrame, rs::Vector{Int}, c::Int) = df[rs, [c]] # delegate
ref{CT}(df::DataFrame{CT}, rs::Vector{Int}, name::CT) = df[rs, [name]] # delegate
# col slices
ref(df::DataFrame, rs::Vector{Int}, c::Int) = df[c][rs]
ref{CT}(df::DataFrame{CT}, rs::Vector{Int}, name::CT) = df[name][rs]

# TODO: other types of row indexing with 2-D slices
# rows are range, vector of booleans
# is there a macro way to define all of these??
Expand Down Expand Up @@ -952,7 +954,7 @@ sub{CT}(D::DataFrame{CT}, b::Vector{Bool}, c::Int) = sub(D, [1:nrow(D)][b], [c])

sub{CT}(D::DataFrame{CT}, r::Int, cs::Vector{Int}) = sub(D, [r], c)
#sub{CT}(D::DataFrame{CT}, rs::Vector{Int}, cs::Vector{Int}) = sub(D, r, [c])
sub{CT}(D::DataFrame{CT}, rng::Range1, cs::Vector{Int}) = sub(D, [r], c)
sub{CT}(D::DataFrame{CT}, rng::Range1, cs::Vector{Int}) = sub(D, [rng], cs)
sub{CT}(D::DataFrame{CT}, b::Vector{Bool}, cs::Vector{Int}) = sub(D, [1:nrow(D)][b], c)

sub{CT}(D::DataFrame{CT}, r::Int, crng::Range1) = sub(D, [r], [crng])
Expand Down

0 comments on commit 183dbfa

Please sign in to comment.