I used to run the following operation using pandas version 0.23.4. Now using pandas 1.3.3 (with Python 3.7) the last line raises "TypeError: Cannot broadcast np.ndarray with operand of type <class 'list'>". Any ideas how to accomplish such operations in the more recent pandas versions? Thanks in advance.
d = {'col1': [1, 2, 3], 'col2': [3, 4, 4]}
df = pd.DataFrame(data=d)
df["example" ] = np.empty((len(df), 0)).tolist()
df.loc[df.col2 == 4, "example"] += [str("A")] # This does no longer work in pandas 1.3.3
This question is related to this post, where however the answer to my question is missing.