# Custom Filtering of rows based on a single column

**URL:** <https://discourse.jupyter.org/t/custom-filtering-of-rows-based-on-a-single-column/9628>\
**Category:** Notebook\
**Tags:** community, how-to, help-wanted\
**Created:** [June 16, 2021, 11:15am UTC](https://discourse.jupyter.org/t/custom-filtering-of-rows-based-on-a-single-column/9628 "2021-06-16T11:15:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mritunjay\_Kumar](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mritunjay_kumar/32/4627_2.png) [@Mritunjay\_Kumar](https://discourse.jupyter.org/u/Mritunjay_Kumar)\
**Post date:** [June 16, 2021, 11:15am UTC](https://discourse.jupyter.org/t/custom-filtering-of-rows-based-on-a-single-column/9628/1 "2021-06-16T11:15:57Z")

</div>

I need to conditionally select more rows just between the values based on a timeline (both the files attached).  
[sample.csv](https://drive.google.com/file/d/1sPQXlj3BNncjfxAhCChZzIWzQaZCLi8t/view)  
[timelines.xlsx](https://drive.google.com/file/d/1w_VHA-0eZJ6cUQB3Re0lO4-9CCVvPHvp/view)

I have a total of 38-time samples in the timeline excel file. I would like to export these specific rows and all columns based on my timeline intervals.

Presently, I am doing it a very hard way by putting each value manually in the code given and then exporting a single excel sheet. Is there a code that can help me reduce my time spent extracting multiple datasets? This would be really helpful.

Here is the present code that I am using

```auto
import pandas as pd
import numpy as np

dat = pd.read_csv('sample.csv')
dat.head(3)

dat = dat[dat[' timestamp'] != 'Mean']
dat = dat[dat[' timestamp'] != 'mean']

dat['time'] = dat [' timestamp'].astype(float)
dat.head(3)

ndat = dat[dat['time'].between(37, 64)] 
ndat.head(2)

ndat.tail(2)

ndat.to_excel('sample1.xlsx)

```

---

<div class="post-metadata">

**Author:** ![Mritunjay\_Kumar](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mritunjay_kumar/32/4627_2.png) [@Mritunjay\_Kumar](https://discourse.jupyter.org/u/Mritunjay_Kumar)\
**Post date:** [June 16, 2021, 11:32am UTC](https://discourse.jupyter.org/t/custom-filtering-of-rows-based-on-a-single-column/9628/2 "2021-06-16T11:32:39Z")

</div>

somebody said, I can append the timelines excel file, convert the values into array and run a loop to extract the rows but based on the timelines excel file, but I don’t how to do that in the code…I am naive in using python and jupyter
