I have a dataframe :
c1 c3 c4 c5
r1 this and
r2 that str shld
r3 have and
The white spaces are chosen to be blank (they were NaN values which I replaced with '' instead)
These strings within the data frame represents error messages, the string only appear when the error is present.
My desired output:
c1 c3 c4 c5 Error_Message
r1 this and this also and
r2 that str shld that also str also shld
r3 have and have also and
My current output:
c1 c3 c4 c5 Error_Message
r1 this and also this also and also
r2 that str shld that also str also also shld
r3 have and have also also and also
The code I am using:
df_calc['Health_Message'] = df_calc['c1'] + ' also ' + df_calc['c3'] +' also ' \
+ df_calc['c4'] + ' also ' + df_calc['c5']
Is there a more pythionic or reliable way to get rid of the unnecessary 'also''s .. there should only be an 'also' between error messages (string values). I am in over my head, thank you