My dataframe looks like this:
datetime1 datetime2 datetime3 datetime4
id
1 5 6 5 5
2 7 2 3 5
3 4 2 3 2
4 6 4 4 7
5 7 3 8 9
and I have a numpy array like this:
index_arr = [3, 2, 0, 1, 2]
This numpy array refers to the index in each row, respectively, that I want to replace. The values I want to use in the replacement are in another numpy array:
replace_arr = [14, 12, 23, 17, 15]
so that the updated dataframe looks like this:
datetime1 datetime2 datetime3 datetime4
id
1 5 6 5 14
2 7 2 12 5
3 23 2 3 2
4 6 17 4 7
5 7 3 15 9
What is the best way to go about doing this replacement quickly? I've tried using enumerate and iterrows but couldn't get the syntax to work. Would appreciate any help - thank you