Python Array Replace Function In R