Stream: helpdesk (published)

Topic: Convert Partition(EachIndex) to DataFrame


view this post on Zulip QuBit (Jul 19 2021 at 17:10):

Hello Everyone:

I have performed a test,train split using:

train, test = partition(eachindex(Ponies), 0.8, shuffle = true)

Then, when I attempt to run a LinearRegressor as:

fm = @formula(Ponies ~ Headshots + Triples + Doubles)
linearRegressor = lm(fm, train)

I am getting the following error:

ArgumentError: expected data in a Table, got Vector{Int64}

The answer is not a simple convert(DataFrame, MagicalCreatureHeadshotDFs)

Is there a way to convert the partittion to a dataframe?

Thank you,

view this post on Zulip Nils (Jul 21 2021 at 09:30):

Well I don't know what Ponies is, but train should be a DataFrame with the columns Ponies, Headshots, Triples, and Doubles for your call to lm to work.

view this post on Zulip QuBit (Jul 21 2021 at 12:41):

Nils

Let's say, Ponies = rand(1: 0.01:15)

I agree -- however, the partition(eachindex(Ponies), 0.8, shuffle = true)
creates an array with two sub-indices (see image). How can I convert
these to a Table?

view this post on Zulip Colin Caine (Jul 21 2021 at 23:09):

table = DataFrame(Ponies=rand(10), Headshots=rand(10))

And then partition the DataFrame.


Last updated: Oct 02 2023 at 04:34 UTC