Possible workarounds for pygmt bug/missing feature?

This might be more of a pandas-based question rather than pygmt, but I feel it’s better to ask here first. I have a geolocated dataframe where I wanna take subsets of data and run pygmt.grdtrack, with a different grid for each subset. That shouldn’t be much of a problem if grdtrack handled dataframe indexes correctly, as I could make a copy of said dataframe slice, and guarantee the output would match the input indexes and I could assign those values to the original df. However, as stated in this report: https://github.com/GenericMappingTools/pygmt/issues/2763
grdtrack doesn’t allow for non default index. My first idea was to run a merge_asof between the output of grdtrack and the original dataframe, but that can’t be done for multiple subsets. I also thought about assuming the order of the points wouldn’t be changed after the grdtrack, so I could assign the output to the same original slice without checking for index, but the order does change when a point falls outside the grid. With all that in mind, is there any way to implement grdtrack to my problem? Thank you very much!

Replying to it as I figured a pretty convenient way:

df['index'] = df.index
df['new']=np.nan
for condition in conditions:
  slice=df[df[condition]][['lon','lat','index']].copy()
  slice.reset_index(drop=True, inplace=True)
  slice=pygmt.grdtrack(grid=grid, points=slice,newcolname='new')
  slice.set_index('index', inplace=True)
  df.update(slice['new'])

It still seems a bit roundabout and will be hoping for a future pygmt update that includes dealing with custom dataframe indexes correctly