【发布时间】:2019-09-11 05:03:15
【问题描述】:
我的数据框看起来像这样 -
Column 1
Event-Won
Event-Won
Event-lost
Event-Won
Event-lost
我想计算事件的数量(赢/输)并显示某个时间戳(当前时间)的计数。我正在使用这个代码,它给了我计数。但我想将时间戳作为输入,并想查看在该特定时间戳上出现了多少次。
from collections import Counter
countval['newValue'].value_counts()
我想要的输出将是 -
Input- current time (timestamp 1)
Output - Event-won -3
Event-lost - 2
Input - future time (timestamp 2)
Output - Event-won - 5
Event-lost - 3
我将不胜感激任何有关此问题的帮助。
【问题讨论】:
-
请给minimal reproducible example说明具体问题。
-
至少显示您的预期输出。
标签: python pandas datetime dataframe data-science