I have the following detaframe bb:
bq_selection_id bq_balance bq_market_id bq_back_price
0 45094462 185.04 7278437 1.97
1 45094462 185.04 7278437 1.97
2 45094463 185.04 7278437 3.05
3 45094463 185.04 7278437 3.05
4 45094464 185.04 7278437 5.80
5 45094464 185.04 7278437 5.80
6 45094466 185.04 7278437 200.00
7 45094466 185.04 7278437 200.00
8 45094465 185.04 7278437 NaN
9 45094465 185.04 7278437 NaN
I would like to group by "market_id" and take first two lowest "bq_back_price". I managed to do this with
bb.groupby('bq_market_id')['bq_back_price'].nsmallest(2)
The problem is that I am missing some of the columns such as "bq_selection_id", "bq_balance" and column "bq_back_price" does not have name. That is what I get
bq_market_id
7278437 0 1.97
7278437 1 1.97
And I would like to get something like this
bq_selection_id bq_balance bq_market_id bq_back_price
0 45094462 185.04 7278437 1.97
1 45094462 185.04 7278437 1.97
Can you help me please?