Python: calculate the most and the least active customers

邮差的信 提交于 2019-12-08 06:21:13

问题


I have a question on how to find the most and the least active customers.

We were given a group of different names. For example "sam, sam, luke, luke, luke"

We are asked to find the most frequent name and the least frequent name using python(spyder). These results need to be reflected in a box in wxFormBuilder.

I am not sure what exactly I should do.

Here is what I have so far for looking for the most active customer:

def mostactive(self,parent):
    for name in range (self.m_listBox1.GetCount()):     <--- the name of the box is m_listBox1
        mostactivecustomer=str(self.m_listBox1.GetString(name))
        self.m_textCtrl2.Value(mostactivecustomer)      <---- the result box is called m_textCtrl2

Thank you!


回答1:


I would guess that this is more a question of basic maths, mean, median, mode etc.

You could put all the names into a list and count the names in each, then write them back to the text box.



来源:https://stackoverflow.com/questions/26127280/python-calculate-the-most-and-the-least-active-customers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!