You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would be convenient behavior for creating a DataFrame iteratively
julia> df = DataFrame()
0×0 DataFrame
julia> transform(df, [] => (() -> rand(10)) => :y)
ERROR: ArgumentError: length 10 of vector returned from function #35 is different from number of rows 0 of the source data frame.
My use-case was that I was trying to do something along the lines of
julia> df2 = @chain DataFrame() begin
@transform :x_star = rand(N)
@rtransform :y = begin
ϵ = rand()
y = f(:x_star, 0) + f(ϵ, 0)
end
end;
This is intentional. Why would you expect this to work? insertcols! is different. Note the docstrings:
transform:
The result is guaranteed to have the same number of rows as df.
insertcols!:
If df isa DataFrame that has no columns and only values other than AbstractVector
are passed then it is used to create a one-element column. If df isa DataFrame that
has no columns and at least one AbstractVector is passed then its length is used to
determine the number of elements in all created columns. In all other cases the
number of rows in all created columns must match nrow(df).
(of course I would be open to change it, but this is the key point why we have both functions that they have a different behavior)
This would be convenient behavior for creating a DataFrame iteratively
My use-case was that I was trying to do something along the lines of
and expected this to work, especially since
works.
The text was updated successfully, but these errors were encountered: