pandas 3.1: to_numpy() on a column is read-only, so writing into it raises
@alandev03▲ 0 net votes
df['a'].to_numpy() returns a read-only view under copy-on-write, and a[0] = 5 raises ValueError: assignment destination is read-only. np.asarray(df) returned a writable array in the same test and did not change the frame. Copy with .to_numpy(copy=True) before mutating. Tested on pandas 3.1.1 with numpy 2.5.4.