# How to view every n-th row in a DataFrame

**URL:** <https://discourse.julialang.org/t/how-to-view-every-n-th-row-in-a-dataframe/55143>\
**Category:** Data\
**Tags:** question, dataframes\
**Created:** [February 12, 2021, 12:14pm UTC](https://discourse.julialang.org/t/how-to-view-every-n-th-row-in-a-dataframe/55143 "2021-02-12T12:14:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)\
**Post date:** [February 12, 2021, 12:14pm UTC](https://discourse.julialang.org/t/how-to-view-every-n-th-row-in-a-dataframe/55143/1 "2021-02-12T12:14:11Z")

</div>

How to view every n-th row in a DataFrame?  
My DataFrame is a plane table of 1334400 x 22 entries. I would like to view every 21-th entire row.  
Could anyone help?

---

<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:** [February 12, 2021, 12:17pm UTC](https://discourse.julialang.org/t/how-to-view-every-n-th-row-in-a-dataframe/55143/2 "2021-02-12T12:17:08Z")

</div>

```julia
df[1:21:nrow(df), :]

```

you might consider `@views df[1:21:nrow(df), :]` to make this quicker and more memory efficient (depening on what you are doing afterwards)

---

<div class="post-metadata">

**Author:** ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)\
**Post date:** [February 12, 2021, 12:21pm UTC](https://discourse.julialang.org/t/how-to-view-every-n-th-row-in-a-dataframe/55143/3 "2021-02-12T12:21:43Z")

</div>

Thanks. What speeks for `nrow(df)` instead of just `end` to set the boundaries?

---

<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:** [February 12, 2021, 1:42pm UTC](https://discourse.julialang.org/t/how-to-view-every-n-th-row-in-a-dataframe/55143/4 "2021-02-12T13:42:09Z")

</div>

Nothing actually - just didn’t think of that!
