I have the following dataframe example and would like to select extract as dictionary the consecutive "id" grouped, will work as a dataframe or matrix too. 

Edit of the dataframe so can clear the confusion

```
sales = [('name', ['C', 'N', 'CA', 'C' , 'N', 'CA','C', 'N', 'CA','C', 'N', 'CA', 'C' , 'N', 'CA', 'C', 'N', 'CA', 'C']),
     ('id', [5, 7, 7, 8, 8, 8, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 2, 18]),
     ('vect1', [210, 90, 200, 210, 90, 200, 200, 210, 90, 200, 210, 90, 200, 210, 90, 45, 200, 210, 90]),
     ('vect2', [210, 90, 200, 210, 90, 200, 140, 215, 95, 340, 215, 95, 240, 215, 95, 65, 200, 210, 90]),
     ('vect3', [210, 90, 200, 210, 90, 200, 240, 115, 35, 340, 115, 35, 140, 115, 35, 35, 200, 210, 90]),
     ]
df = pd.DataFrame.from_items(sales)#len1919

selected = df['name'].groupby(df['id']) 
gr_data = df.groupby('name')

```

Dataframe is not limited to this observations and id (id can start at any number in the dataset but will extract only consecutive ones), what I try to get is ***n, n+1, n+2, n+3*** , this is for **id** column the consecutiveness but should follow strict order as is the name, tried to group but does't work the way I need ...

this is what i'm looking for as a consecutive order: 

```
dC13 =[{...},
   {(C, 13): [200,  140,    240]},
   {(N, 14): [210,  215,    240]},
   {(CA, 14): [90,  95, 35]},
   {(C, 14): [200,  340,    340]},
   {(N, 15): [210,  215,    115]},
   {(CA, 15): [90,  95, 35]},
   {(C, 15): [200,  240,    140]},
   {(N, 16): [210,  215,    115]},
   {(CA, 16): [90,  95, 35]},
   {(C, 16): [45,   65, 35]},
   {...}]

```

So final result will be like following: 

```
 dC_n =[{...},
   {(C, n): [200,   140,    240]},
   {(N, n+1): [210, 215,    240]},
   {(CA, n+1): [90, 95, 35]},
   {(C, n+1): [200, 340,    340]},
   {(N, n+2): [210, 215,    115]},
   {(CA, n+2): [90, 95, 35]},
   {(C, n+2): [200, 240,    140]},
   {(N, n+3): [210, 215,    115]},
   {(CA,n+3): [90,  95, 35]},
   {(C, n+3): [45,  65, 35]},
   {(N, n+4): [210, 215,    240]},
   {(CA, n+4): [90, 95, 35]},
   {(C, n+4): [200, 340,    340]},
   {(N, n+5): [210, 215,    115]},
   {(CA, n+5): [90, 95, 35]},
   {(C, n+5): [200, 240,    140]},
   {(N, n+6): [210, 215,    115]},
   {(CA,n+6): [90,  95, 35]},
   {(C, n+6): [45,  65, 35]},
   {(N, n+7): [210, 215,    115]},
   {(CA,n+7): [90,  95, 35]},
   {(C, n+7): [45,  65, 35]},
   {(N, n+8): [210, 215,    240]},
   {(CA, n+8): [90, 95, 35]},
   {(C, n+8): [200, 340,    340]},
   {(N, n+9): [210, 215,    115]},
   {(CA, n+9): [90, 95, 35]},
   {(C, n+9): [200, 240,    140]},
   {(N, n+10): [210,    215,    115]},
   {(CA,n+10): [90, 95, 35]},
   {(C, n+10): [45, 65, 35]},
   {...}]

```

### vectors are just sample.

P.S: from comments adding details: 

The key is the combination from name and id column, values is the vect1, vect2, vect3. 

What I try to do is the output to be only as a consecutive id from having exactly forming this "pattern": **C\_n', 'N\_n+1', 'CA\_n+1', 'C\_n+1' , 'N\_n+2', 'CA\_n+2','C\_n+2'**, followed by new sequence **C\_n+2', 'N\_n+3', 'CA\_n+3', 'C\_n+3' , 'N', 'CA','C'** where 'C\_n' is the . Example does show sample of how should look with consecutive, so in this case n=13, n+1=14 , n+2 = 15 etc than another pattern in the same dataset can start over n=18, n+1=19 (checking everything with id=19), n+2=20(checking everything with id=20) etc.

I create the tuple as a combination of 2 columns from above:

```
df['new_col'] = list(zip(df.name, df.id))

```

So in the dataset **C', 'N', 'CA', 'C' , 'N', 'CA','C'** is not all time consecutive (C = 5, N= 13, CA= 13 will not be a pattern looking for because **id** is not consecutive ... ), I just look at consecutive ones and output them as a dictionary or will work as a dataframe/matrix too, multiple dictionaries composing from this patter with consecutive **id** : C', 'N', 'CA', 'C' , 'N', 'CA','C'.

I listed as dictionary because ultimately i can convert dict to dataframe as: 

```
df_readyC13 = pd.DataFrame(dC13)
df_readyC_n = pd.DataFrame(dC_n) #where C_n is the sstart of the new consecutive sequence C', 'N', 'CA', 'C' , 'N', 'CA','C'

```

I'm thinking that for every disconnected pattern 'C', 'N', 'CA', 'C\_n+1' , 'N', 'CA','C' (non consecutive id for ) **C\_n** having patter for consecutive **name, id** *C', 'N', 'CA', 'C' , 'N', 'CA','C'* create a dictionary dC13, dC14, d15 ... where d\_n is the name for each "C\_n".