I am new here, so please don't be to hard on me! :)
See picture below!
I am trying to create a new dataframe (df['New_df']) based on the values in df['Datan'] so that df['New_df'] is equal to df['Datan'] on the rows where the string #SRU appears. If the string is not in df['Datan'], I want df['New_df'] to "keep" the value of the row above (where the #SRU string was included).
See below df of what I am trying to do.
Datan New_df
#SRU 1512 7251 #SRU 1512 7251
#KONTO 1513 "Kundfordringar - delad faktura" #SRU 1512 7251
#SRU 1513 7251 #SRU 1513 7251
#KONTO 1519 "Nedskrivning av kundfordringar" #SRU 1513 7251
#SRU 1519 7251 #SRU 1519 7251
I have been trying around with for loops combined with if statements with the apply method in particular but haven't reached a solution as of yet. Not able to find this specific problem in any other threads here.
![Print screen: df['Datan]](https://i.stack.imgur.com/w8HHt.png)