熊猫有没有办法将一列汇总为均值,而另一列则是计数?
我找不到任何地方的解决方案。我要实现的目标是: dataFrame 由'Machine'列分组,接下来是平均列'datetime',最后一个作为一个'条形码'的计数。
不工作尝试:
result = df.groupby('Machine')['datetime'].aggregate('mean')['Barcode'].aggregate('count')
[1]: https://i.sstatic.net /h8hiv.png < - 操作之前的dateframe
I cannot find solutions to that anywhere. What I am trying to achieve is: dataframe grouped by 'Machine' column, next would be average column 'datetime' and last one as a count of 'Barcode'.
Not working attempt:
result = df.groupby('Machine')['datetime'].aggregate('mean')['Barcode'].aggregate('count')
[1]: https://i.sstatic.net/h8HiV.png <-- dateFrame before operation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)