Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2015 23:19
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Julialang DataFrame & Matrix mappings
@doc doc"""
Takes a 2d array where each column is a pattern which maps to a row in
the resulting dataframe. Each pattern index is its own column in
the dataframe.
""" ->
function DataFrame(data::Array{Float64, 2})
m = data'
result = DataFrame()
for i in 1:size(data, 1)
result[i] = m[:, i]
return result
@doc doc"""
Takes a dataframe and returns a matrix and an array of column names.
Each row in the dataframe become a column in the matrix.
""" ->
function Array(data::DataFrame)
m = Array(Float64, size(data))
for i in 1:size(data, 2)
m[:, i] = data[:, i]
return m', data.colindex.names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment