2017-11-03 1 views
1

출력이 이고 아래에 표시된 것처럼 DataFrame으로 변환해야합니다.Julia의 단일 차원 배열을 DataFrame으로 변환

x = rand(4) 
4-element Array{Float64,1}: 
0.951252 
0.936421 
0.773268 
0.207913 

p = convert(DataFrame, x) // Why this doesn't work ? 

이 결과 :

MethodError: Cannot convert an object of type Array{Float64,1} to an object of type DataFrames.DataFrame This may have arisen from a call to the constructor DataFrames.DataFrame(...), since type constructors fall back to convert methods.

이 작동하지 않는 이유는 무엇입니까?

답변

4

DataFrame에 열 이름이 필요하다고 생각합니다. 당신은 줄리아와 함께 문제가 있다면 좋은 시작 도움을 사용하는 것입니다

julia> df = DataFrame(column_name = x) 
4×1 DataFrames.DataFrame 
│ Row │ column_name │ 
├─────┼─────────────┤ 
│ 1 │ 0.349747 │ 
│ 2 │ 0.718652 │ 
│ 3 │ 0.0984634 │ 
│ 4 │ 0.553987 │ 

: 당신은 예를 들어이 사용할 수

julia>?DataFrame 

를 누르면? 첫 번째 문자 프롬프트가

help?> DataFrame 

으로 변경되면이 예에서는 도움말을 볼 수 있습니다.

일부 자습서 일 수 있습니다. 예를 들어 wikibook도 도움이 될 수 있습니다.

관련 문제