I have a dataframe that looks like:
Col1 Col2 ..... Col48
078 abc 0.99
097 def 0.91
027 xyz 0.66
065 90 0.76
I want to add new row after the last row with all values '0' in it. So the new df should look like:
Col1 Col2 ..... Col48
078 abc 0.99
097 def 0.91
027 xyz 0.66
065 bcd 0.76
0 0 0
After this, I want to replace the Col2 value from 0 to 'Target so the final dataframe would look like:
Col1 Col2 ..... Col48
078 abc 0.99
097 def 0.91
027 xyz 0.66
065 bcd 0.76
0 target 0
Code:
df.loc[len(df)] = 0
df['Col2'] = df['Col2'].astype(str)
df['Col2'].str.replace('0','target')