'How to improve Python's code speed - Panda Dataframe

I'm new to python and panda, i have a huge dataframe of 2 000 000 rows and 2 columns (small example below)

RECEIVER TRANSMITTER
UEXRT4E 458ERT56
URTU5FE 458ERT57

And an other one with 304 Receivers.

RECEIVER Number Received
UEXRT4E 25002
URTU5FE 15004
UFTX5FE 10500

I want to delete every transmitters received by each receivers in the huge dataframe.

To do so I have 2 while running. One to get all transmitters receive by receiver n°1 then 2 etc...

Then an other one to delete all the rows where i see the transmitters.

Variable "u" starts at 0.

 while(u<VCbrutD): 
    uE = CbrutD['TRANSMITTER'].iloc[u] #get the transmitter
    Cbrut.drop(Cbrut[Cbrut['TRANSMITTER'] == uE].index, inplace = True) #delete every input of it 
    u = u + 1
    print(u)

VcbrutD is the max lenght of the previous request where i get all the transmiters for receiver n°1 in my 304 receivers's list.

Cbrut is my huge dataframe with 2 000 000 rows.

First loop isn't taking too much time for getting all the transmitter for one receiver, but unfortunately the second while is taking years to compute.

Moreover i do not want to delete everything at the same time as it is important to start from the receiver with the highest number received then the second one etc..

Any idea how to improve this loop ?

Thanks everyone !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source