0

Here is the code:

x = 0
y = 0

while x <= len(well_1984):

    if y==len(well):
        
        break

    if str(well_628["uwi"][y]) in str(well_1984["UNITS FIELD"][x]):

        well_1984 = well_1984.drop(index = x, axis=0)
        
        a = x + 1000000
        j = x + 1

        while j <= a:

            if "perforation" in str(well_1984["UNITS FIELD"][j]):
                well_1984 = well_1984.drop(index = j, axis=0)
            elif "squeeze" in str(well_1984["UNITS FIELD"][j]):
                well_1984 = well_1984.drop(index = j, axis=0)
            elif "WELLNAME" in str(well_1984["UNITS FIELD"][j]):
                break
            j += 1

        x += j
        y = y + 1
        print(x,y)
    
    else:

        x += 1

i tried to erase some rows for specified conditions (if there is a match between well name and the data then erase the row containing well name and all of rows below it untuil meet new row that contain "WELLNAME") like this:

example data

  • Does this answer your question? [Conditional Replace Pandas](https://stackoverflow.com/questions/21608228/conditional-replace-pandas) – Hannon qaoud Sep 23 '22 at 09:32

0 Answers0