Using tail method (docs) works.
last_row = a.tail(1)
last_row.loc[:, 'a'] = 4.0
Apparently it has to be separated into two instructions, because it raises the following warning otherwise:
FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0!