# Nested Task error: Bad window span - what?

**URL:** <https://discourse.julialang.org/t/nested-task-error-bad-window-span-what/67959>\
**Category:** Data\
**Tags:** question, dataframes\
**Created:** [September 9, 2021, 9:57pm UTC](https://discourse.julialang.org/t/nested-task-error-bad-window-span-what/67959 "2021-09-09T21:57:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [September 13, 2021, 7:26pm UTC](https://discourse.julialang.org/t/nested-task-error-bad-window-span-what/67959/5 "2021-09-13T19:26:46Z")

</div>

try this way (I don’t know if simple and efficient)

the scheme used [here](https://discourse.julialang.org/t/how-to-compute-a-cumulative-in-a-dataframe-without-a-for-loop/2156/44)

```julia

using ShiftedArrays, DataFrames,RollingFunctions, Query

bigDf = DataFrame(i = 1:100, Growth = rand(100), Categories = rand(["a", "b", "c", "d", "f", "g"], 100))

TimedDfTest = @linq bigDf |>
         groupby(:Categories) |>
         transform(Trailing = running(prod, (:Growth .+1), 3).-1)

runshp(arr, sh) =cumprod(arr)./ShiftedArray(cumprod(arr),sh,default=1)
       
withOnlySA=transform(groupby(bigDf, :Categories),:Growth => (x -> runshp(x.+1, 3).-1) => :Trailing)       

```

considera che

```julia

julia> withOnlySA.Trailing ≈ TimedDfTest.Trailing
true

julia> runshp([1,2,3,4],5)
4-element Vector{Float64}:
  1.0
  2.0
  6.0
 24.0

```

---

_[View the full topic](https://discourse.julialang.org/t/nested-task-error-bad-window-span-what/67959)._
