我正在遍历一个包含来自SQL数据库的数据的字典,我想计算user
值出现在initial_date
和{
initial_date = datetime(2017,09,01,00,00,00)
ending_date = datetime(2017,09,30,00,00,00)
dictionary sample that I got
sample = {'id': 100008222, 'sector name': 'BONGOX', 'site name': 'BONGO', 'region': 'EMEA',
'open date': Timestamp('2017-09-11 00:00:00'), 'mtti': '16', 'mttr': '1', 'mttc': '2','user':'John D.'},
{'id': 100008234, 'sector name': 'BONGOY', 'site name': 'BONGO', 'region': 'EMEA',
'open date': Timestamp('2017-09-09 12:05:00'), 'mtti': '1', 'mttr': '14', 'mttc': '7','user':'John D.'}
{'id': 101108234, 'sector name': 'BONGOA', 'site name': 'BONGO', 'region': 'EMEA',
'open date': Timestamp('2017-09-01 10:00:00'), 'mtti': '1', 'mttr': '12', 'mttc': '1','user':'John C.'}
{'id': 101108254, 'sector name': 'BONGOB', 'site name': 'BONGO', 'region': 'EMEA',
'open date': Timestamp('2017-09-02 20:00:00'), 'mtti': '2', 'mttr': '19', 'mttc': '73','user':'John C.'}
这是我用来计算user
值出现在initial_date
和{
上面的代码不起作用,因为我遇到错误decoding to str: need a bytes-like object, Timestamp found
我有两个问题:
user
值出现的次数,以达到我想要的结果?在
使用
Timestamp.to_datetime()
转换为datetime
对象使用来自
pandas
的class Timestampe
使用
^{pr2}$Counter()
没有
Counter()
用Python:3.4.2测试
相关问题 更多 >
编程相关推荐