I have large DataFrame with GPS path and some attributes. A few sections of the path are those which I need to analyse. I would like to subset only those sections to a new DataFrame. I can subset one section at the time but the idea is to have them all and to have an original index.
The problem is similar to:
import pandas as pd
df = pd.DataFrame({'A':[0,1,2,3,4,5,6,7,8,9],'B':['a','b','c','d','e','f','g','h','i','j']},
index=range(10,20,))
I want o get something like:
cdf = df.loc[[11:13] & [17:20]] # SyntaxError: invalid syntax
desired outcome:
A B
11 1 b
12 2 c
13 3 d
17 7 h
18 8 i
19 9 j
I know the example is easy with cdf = df.loc[[11,12,13,17,18,19],:]
but in the original problem I have thousands of lines and some entries already removed, so listing points is rather not an option.