There’s a deeper conceptual problem here: what format is the data stored in?
There are two coherent formats involving Dict’s that can be converted:
Dict{Vector} and Vector{Dict}.
Dict{Vector} looks something like this in 0.4 notation:
input Dict(
:a => [1, 2],
:b => [2, 3]
)
This is a column-oriented format and seems to be what DataFrames assumes your
Dict represents.
Vector{Dict} looks something like this:
input = [
Dict(:a => 1, :b => 2),
Dict(:a => 2, :b => 3),
]
This is a row-oriented format and seems to resemble what you’re both using.
I have a work-in-progress to support these two styles of input that should land
in another month or so.
— John
On Oct 19, 2014, at 9:32 AM, [email protected] wrote:
> On Wednesday, October 15, 2014 1:09:01 AM UTC+2, James Kyle wrote:
>> So I tried:
>>
>> convert(DataFrame, dict_data)
>>
>> This returns
>>
>> ERROR: ArgumentError("All columns in Dict must have the same length")
>> in convert at
>> /Users/jkyle/.julia/v0.3/DataFrames/src/dataframe/dataframe.jl:1001
>
> I had this same problem just now. The problem is that you (and I!) have
> string values in the dictionary. The convert function looks at the length of
> the strings and see a vector of characters, and these are not conformable to
> the unit-length values in the non-string entries.
>
> My workaround was creating the dataframe from a dictionary where all the
> strings had been cut to a single character. When the dataframe is created, I
> could update the values with the actual (and longer) string values. Not
> beautiful, but it works for now.
>
> One of the motivations creating the dataframe from a dict is that the set of
> columns is not always known, it would be useful if the convert function could
> allow for string-values. Are there experts who know if this would be possible?
>
> Best regards,
> Erik Ø. Sørensen.
>
>
>