Convert Julia array to dataframe

前端 未结 4 380
遇见更好的自我
遇见更好的自我 2021-01-13 12:53

I have an array X that I\'d like to convert to a dataframe. Upon recommendation from the web, I tried converting to a dataframe and get the following error.

j

4条回答
  •  爱一瞬间的悲伤
    2021-01-13 13:43

    This works for me:

    julia> using DataFrames
    
    julia> x = rand(4, 4)
    4x4 Array{Float64,2}:
     0.790912  0.0367989  0.425089  0.670121
     0.243605  0.62487    0.582498  0.302063
     0.785159  0.0083891  0.881153  0.353925
     0.618127  0.827093   0.577815  0.488565
    
    julia> convert(DataFrame, x)
    4x4 DataFrame
    | Row | x1       | x2        | x3       | x4       |
    |-----|----------|-----------|----------|----------|
    | 1   | 0.790912 | 0.0367989 | 0.425089 | 0.670121 |
    | 2   | 0.243605 | 0.62487   | 0.582498 | 0.302063 |
    | 3   | 0.785159 | 0.0083891 | 0.881153 | 0.353925 |
    | 4   | 0.618127 | 0.827093  | 0.577815 | 0.488565 |
    

    Are you trying something different?

    If that doesn't work try posting a bit more code we can help you better.

提交回复
热议问题