我正在尝试获取每个客户的最新数据,而不考虑数据框中的其他属性
我的数据框看起来像这样
我的输出应该是这样的
我尝试了'df.iloc[df.groupby('customer')['date'].idxmax()
“ValueError回溯(最近一次调用上次) 在里面 ---->;1 df=df.iloc[df.groupby('cutomer')['date'].idxmax()]
包装中的~\Anaconda3\envs\myenv\lib\site packages\pandas\core\groupby\groupby.py(*args,**kwargs) 653如果self.obj.ndim==1: 654#这可以递归调用,因此需要引发ValueError -->;655上升值错误 656 657#GH#3688试着逐项操作
值错误:“
我认为它实际上和这个一样:similar problem
在这种情况下,代码如下所示:
相关问题 更多 >
编程相关推荐