# An unexpected result using DataFrames.jl

**URL:** https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249
**Category:** New to Julia
**Tags:** dataframes
**Created:** [May 10, 2020, 10:55pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249 "2020-05-10T22:55:32Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![ameresv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameresv/32/14372_2.png) [@ameresv](https://discourse.julialang.org/u/ameresv)
#### Post date: [May 10, 2020, 10:55pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/1 "2020-05-10T22:55:32Z")

</div>

Hi! Following JuliaAcademy, I had found something that results confusing.

```julia
using DataFrames, Random

function sim_e()
    draw = Float64[]
    while true
        push!(draw, rand())
        sum(draw) > 1.0 && return draw
    end
end 

Random.seed!(1234);
res = [sim_e() for _ in 1:5]

sum.(res)

@. sum(res) - last(res)

df = DataFrame()

@time for i in 1:10^7
    push!(df, (id=i, pos=sim_e()))
end

df

transform!(df, :pos => ByRow(length) => :jumps)

```

This code has to deliver the following, according to the tutorial:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/9/89682c562ce9a53fd21f816d0769e2c44f3334bf.png)  
However, I obtain this error message:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/a/cafe7e11f3be9be48f42f03f2db0c03b9e116192.png)  
Which is nonsense considering that I have been using DataFrames.jl during the course.  
Did I do something wrong?  
Regards

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [May 11, 2020, 6:09am UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/2 "2020-05-11T06:09:50Z")

</div>

Works for me - are you sure you’re on the latest version of DataFrames?

---

<div class="post-metadata">

### Author: ![ameresv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameresv/32/14372_2.png) [@ameresv](https://discourse.julialang.org/u/ameresv)
#### Post date: [May 11, 2020, 5:29pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/3 "2020-05-11T17:29:53Z")

</div>

I am using DataFrames v0.20.2.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/c/3cbee02b5d0d35fe343351084cc34a0ca0f619ef.png)

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 11, 2020, 5:30pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/4 "2020-05-11T17:30:53Z")

</div>

Can you run `import Pkg; Pkg.update()`? The latest version is `v0.21.0`. All those fun things are defined only for the newest version of DataFrames.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [May 11, 2020, 5:46pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/5 "2020-05-11T17:46:30Z")

</div>

Don’t think that will work given the output of `pkg> up` above - something might be holding you back, try `add DataFrames@0.21` to see what’s restricting the DataFrames version.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 11, 2020, 5:48pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/6 "2020-05-11T17:48:46Z")

</div>

good call. OP should probably start their own environment for the julia academy tutorial. but that’s a bit scary for a new comer. This is unfortunate.

---

<div class="post-metadata">

### Author: ![js135005](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/js135005/32/8219_2.png) [@js135005](https://discourse.julialang.org/u/js135005)
#### Post date: [May 11, 2020, 5:49pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/7 "2020-05-11T17:49:18Z")

</div>

If you use ODBC, that holds DataFrames back at v0.20.2 at the moment.

---

<div class="post-metadata">

### Author: ![ameresv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameresv/32/14372_2.png) [@ameresv](https://discourse.julialang.org/u/ameresv)
#### Post date: [May 11, 2020, 5:54pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/8 "2020-05-11T17:54:16Z")

</div>

Hi! Thanks for your answer. Following your suggestion, this message appears:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/1/c13fc4d331eb6075fd10ff8e8595ef0ce2fd1b31.png)

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [May 11, 2020, 5:56pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/9 "2020-05-11T17:56:07Z")

</div>

Okay so you can do `]rm MLJ` to remove MLJ (if you don’t need it now!) - MLJ currently restricts compatibility to DataFrames below 0.21 so won’t let you update.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 11, 2020, 6:05pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/10 "2020-05-11T18:05:55Z")

</div>

OP, the way to really avoid this problem is to create a new folder and use julia to `cd` into it. Then run `import Pkg; Pkg.activate(".")`.

After that, add all the packages you need to get through the JuliaAcademy course.

So something like this, which you only need to run once.

```julia
import Pkg
mkdir("JuliaAcademyCourse")
cd("JuliaAcademyCourse")
Pkg.activate(".")
Pkg.add("DataFrames")
# add other packages

```

Then if you close and re-open your julia terminal, you just need to do set Julia to the folder above and run `import Pkg; Pkg.activate(".")`.

If this is too complicated, don’t worry about it. You can just focus on removing `MLJ` like the poster above mentioned and trying to update DataFrames again.

---

<div class="post-metadata">

### Author: ![ameresv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameresv/32/14372_2.png) [@ameresv](https://discourse.julialang.org/u/ameresv)
#### Post date: [May 11, 2020, 6:57pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/11 "2020-05-11T18:57:35Z")

</div>

Thanks for your support. The problem looks fixed. The downside is that now appears these messages that I encountered a bit difficult to understand by the time to using Statistics and GLM.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/8/888e4203590c3597efbdbfbb14dfe3c15882d4a8.png)  
What does it mean?

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 11, 2020, 8:17pm UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/12 "2020-05-11T20:17:42Z")

</div>

These should all be fine as long as the code works. I couldn’t explain what all of them mean, though.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [May 12, 2020, 6:08am UTC](https://discourse.julialang.org/t/an-unexpected-result-using-dataframes-jl/39249/13 "2020-05-12T06:08:52Z")

</div>

They shouldn’t worry you - and also they should go away once you restart Julia.
