I have generated the dataframe below in python which has had a groupby operation used on it to find the max Daily Oil's for each company:
DailyOilMax = dftblOilWells.groupby(['Operator Company Name',"Reservoir"])['Daily Oil'].max().reset_index().sort_values(by='Daily Oil', ascending=False).reset_index()
Output: [1]: https://i.stack.imgur.com/Y7kPu.jpg
Now I want to go back to the original dataframe below and filter it based on the results above: [1]: https://i.stack.imgur.com/k5IwP.jpg
I've tried merge, iloc, but feel like I may need a function for this to work.
dfTest = dfOilWells.loc[dfOilWells.['Daily Oil'].isin(DailyOilMax['Daily Oil'])]
I felt close with the code above but couldn't figure out the syntax if my column has a space in it.