0

I'm working on these huge dataset - so I was selecting a special type of data but also the index of the selected rows was taken over. i.e

df = pd.DataFrame({'a': [2016,2016,2016,2016,2016,2016,2016,2016,2016,2016], 
                   'b' : [32,31,32,31,31,32,32,32,32,32],
                   'c':[6,7,12,12,23,1,2,67,8,34})

       a            b           c       
0     2016         32           6
1     2016         31           7    
2     2016         32           12
3     2016         31           12
4     2016         31           23    
5     2016         32           1
6     2016         32           2
7     2016         32           67
8     2016         32           8
9     2016         32           34

df_new = df[df.b == 31]

       a            b           c       
1     2016         31           7    
3     2016         31           12
4     2016         31           23  

after reducing my Dataframe I've no idea how to reindex my new collection of data. I tried .reindex, .reset_index, .set_index ... I still can't get away from my old index. Do someone got a solution for this issue? Cheers and thanks

2
  • Do you need df_new = df_new.reset_index(drop=True) ? Commented Apr 9, 2020 at 6:48
  • 1
    Hey ... wow okay you solved my prob - thx a lot buddy ! #shameonme Commented Apr 9, 2020 at 7:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.