How can I update an array based on the nearest value in a pandas DataFrame column? For example, I'd like to update the following array based on the "Time" column in the pandas DataFrame so that the array now contains the "X" values:
Input array:
a = np.array([
[122.25, 225.00, 201.00],
[125.00, 151.50, 160.62],
[99.99, 142.25, 250.01],
])
Input DataFrame:
df = pd.DataFrame({
'Time': [100, 125, 150, 175, 200, 225],
'X': [26100, 26200, 26300, 26000, 25900, 25800],
})
Expected output array:
([
[26200, 25800, 25900],
[26200, 26300, 26300],
[26100, 26300, 25800],
])