So somehow a simple addition of a string in front of strings as part of a column within a subset of my dataframe, is not working. Without getting an error message, the new string does not apply the addition to column_1, based on the selected subset of the matching value in column_2.
The below code works and the output adds the 'w' in front of the strings in the subset selection.
'w' + df[(df.column_2 == 'af')]['column_1'].astype(str)
This code outputs the desired result for the selected columns. Where the code below should apply it to the df, it does not seem to add the 'w' to the dataframe subset.
df[(df.column_2 == 'af')]['column_1'] = 'w' + df[(df.column_2 == 'af')]['column_1'].astype(str)
What am I missing here?