0

i have data as follows -

tag1 tag2 tag3 originalNumber
A    sat  nov                
A    sat  jan  1
A    sat  feb
A    sat  mar  
A    sun  jan  2
A    sun  dec 
B    abc  cde  1
B    abc  bde  
B    abc  fde  
B    ebc  cde  2

Now i am trying to create a new column, if originalNumber is empty take last non empty originalNumber available . e.g. -

 tag1 tag2 tag3 originalNumber newNumber
    A    sat  nov                
    A    sat  jan  1              1
    A    sat  feb                 1
    A    sat  mar                 1
    A    sun  jan  2              2
    A    sun  dec                 2
    B    abc  cde  1              1
    B    abc  bde                 1
    B    abc  fde                 1
    B    ebc  cde  2              2
user1122
  • 297
  • 2
  • 9
  • 15
  • You could have just googled "pandas forward fill NaN" (which is what I did to find your answer, a single function) – cs95 Jul 22 '18 at 00:02
  • thanks! It helped. I am learning pandas was not sure about forward fill. – user1122 Jul 22 '18 at 00:05

0 Answers0