Select Pandas rows based on list index

前端 未结 5 645
滥情空心
滥情空心 2020-11-28 03:37

I have a dataframe df :

   20060930  10.103       NaN     10.103   7.981
   20061231  15.915       NaN     15.915  12.686
   20070331   3.196       NaN               


        
5条回答
  •  醉梦人生
    2020-11-28 03:55

    Another way (although it is a longer code) but it is faster than the above codes. Check it using %timeit function:

    df[df.index.isin([1,3])]
    

    PS: You figure out the reason

提交回复
热议问题