Question: I have pandas Dataframe (70 000 rows) like this:

| No | Time | Length |
| --- | --- | --- |
| 1 | 2.12079 | 60 |
| 2 | 2.581 | 12 |
| 3 | 2.7172 | 60 |
| 4 | 3.43883 | 60 |
| 5 | 3.6883 | 54 |
| 6 | 3.7233 | 54 |
| ... | ... | ... |
| 70 000 | 172.2777 | 24 |

In column Time i have values in float type representing time in seconds. I need to drop rows that has duplicates in length but just in range of 1 second. So my output
should look like this:

| No | Time | Length |
| --- | --- | --- |
| 1 | 2.12079 | 60 |
| 2 | 2.581 | 12 |
| 4 | 3.43883 | 60 |
| 5 | 3.6883 | 54 |
| ... | ... | ... |

Can somebody help me?

Answer: 
Maybe this is what you seek?

```
df["int_time"] = df["Time"].astype(int)
print(
    df.groupby(["Length", "int_time"], as_index=False)
    .first()
    .sort_values(by="No")
    .drop(columns="int_time")
)

```

Prints:

```
   Length     No       Time
3      60      1    2.12079
0      12      2    2.58100
4      60      4    3.43883
2      54      5    3.68830
1      24  70000  172.27770

```
I'm very confused by your example output, but based on your description, and assuming the dataframe is already sorted by time: you could make a new column containing the difference between the time in row x and the time in row x-1:

```
df['Diff'] = df['Time'].diff()

```

Then drop the rows where Diff > 1

```
df['Diff'] = df['Diff'].fillna(999)  # make sure first row doesn't get deleted
df = df[df['Diff'] > 1].drop(['Diff'],axis=1)  # filter and drop the temporary "Diff" column

```