Repeat code for the same product group [closed]

-3

I have a spreadsheet with thousands of products as the example below, where the code is only in the type of service (left column), and I want it to appear in all products of the same type (right column). In practice, I want code '1' to be dragged to code 2, and this to code 3, and so on. Is there anything ready in pandas for that?

    
asked by anonymous 22.12.2018 / 00:42

1 answer

1
df.fillna('', inplace=True)

while('' in df['CODIGO'].values):

    df.loc[df['CODIGO'] == '', 'CODIGO'] = df.loc[:, 'CODIGO'].shift(1)
    
22.12.2018 / 02:41