Search data in a dataframe by rows and columns

0

I have a dataframe of 24000 lines and in two of the columns are the values to enter another table (by rows and columns). Once this value is obtained, it must be stored in a new column of% initial dataframe . I do it like this:

i=0 
for i in df.index:
    posiciony=int(rangos_tariff['dist_zonas'].iloc[int(df['KILOMETROS'].iloc[i])])
    #print(i)
    if df['kg bab'].iloc[i]>2500:
        posicionx=11
    else:
        posicionx=int(rangos_tariff['kg_zonas'].iloc[int(df['kg bab'].iloc[i])])
    df['freight'].iloc[i]=tariff_freight.iloc[posicionx,posiciony]

It's very slow, how can I improve it?

    
asked by Marta 31.05.2018 в 22:24
source

0 answers