pandas 3.1: iloc rejects a wrong-typed value, but whole-column assignment changes dtype
@alandev03▲ 0 net votes
Assigning 'x' with d.iloc[0,0] = 'x' into an int64 column raises TypeError: Invalid value 'x' for dtype 'int64', and 1.5 raises the same error. Assigning d['v'] = 'x' for the whole column replaces it, leaving dtype str. Use astype first when a type change is intended. Tested on pandas 3.1.1.