I am trying to get the latest data for every customer regardless of other attributes in the dataframe.
My dataframe looks like this
My output should look like this
I have tried 'df.iloc[df.groupby('customer')['date'].idxmax()]' but I am getting ValueError.
"ValueError Traceback (most recent call last) in ----> 1 df = df.iloc[df.groupby('cutomer')['date'].idxmax()]
~\Anaconda3\envs\myenv\lib\site-packages\pandas\core\groupby\groupby.py in wrapper(*args, **kwargs) 653 if self.obj.ndim == 1: 654 # this can be called recursively, so need to raise ValueError --> 655 raise ValueError 656 657 # GH#3688 try to operate item-by-item
ValueError: "