JuliaAcademy/DataScience

insertcols in DataFrames has a breaking change

Closed this issue · 4 comments

The Clustering notebook includes 5 calls insertcols! that may no longer work due to a recent breaking change in DataFrames.jl.

While there are 5 instances of insertcols! in the Clustering notebook, I am specifically failing on the first one on line 296. This fails in the same way on both nteract and jupyter.

MethodError: no method matching insertcols!(::DataFrame, ::Int64, :String)

Hey @nassarhuda if you get a chance, can you take a look at this?

I am also facing the same issue.

Code (first instance when insertcols is used):
bucket_price = Int.(div.(houses_data[!, :median_house_value], 50000)); insertcols!(houses_data, 3, cprice=bucket_price)

Error:

ArgumentError: inserting columns using a keyword argument is not supported, pass a Pair as a positional argument instead

Stacktrace:
[1] #insertcols!#182 at C:\Users\shaks.julia\packages\DataFrames\yqToF\src\dataframe\dataframe.jl:828 [inlined]
[2] top-level scope at In[9]:3
[3] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

What is a possible workaround to this situation?

No issues, got it resolved.

Replacing insertcols!(houses_data, 3, cprice=bucket_price) by insertcols!(houses_data, 3, :cprice => bucket_price) works.

Updated! Thanks for pointing this out.