# Indices of a sub-dataframe

**URL:** <https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650>\
**Category:** Data\
**Tags:** dataframes\
**Created:** [March 27, 2023, 9:21am UTC](https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650 "2023-03-27T09:21:55Z")\
**Posts on this page:** 4\
**Page:** 2

<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:** [March 30, 2023, 9:01am UTC](https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650/21 "2023-03-30T09:01:55Z")

</div>

> [@bkamins](#):
>
> not always return exactly what I assume was originally expected:

could you clarify this, please?

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [March 30, 2023, 9:06am UTC](https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650/22 "2023-03-30T09:06:19Z")

</div>

> [@rocco\_sprmnt21](#):
>
> could you clarify this, please?

Look at the example above - you get indices of the root `DataFrame`, not `SubDataFrame` that was used to do `groupby`.

The reason is that `view`s in Julia always refer to root object and do not stack.

---

<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:** [March 30, 2023, 9:08am UTC](https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650/23 "2023-03-30T09:08:55Z")

</div>

Yes, I saw. but why do you say that you expected different results from the two forms?

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [March 30, 2023, 10:33am UTC](https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650/24 "2023-03-30T10:33:20Z")

</div>

> [@rocco\_sprmnt21](#):
>
> you expected different results from the two forms?

I say that the user would probably expect to get row indices of `SubDataFrame` that was used to create `GroupedDataFrame` as this is a natural thing to ask for.

[Previous page](https://discourse.julialang.org/t/indices-of-a-sub-dataframe/96650.md?page=1)
