Exemplo n.º 1
0
 def height_statistic(self):
     userData = mongo_collection.find()
     h = {'ht0': 0}
     for i in range(144, 192, 1):
         h['ht' + str(i)] = 0
     for item in userData:
         try:
             height = float(item["height"])
         except ValueError:
             height = 0
             h['ht0'] += 1
         if height <= 144:
             h['ht' + str(144)] += 1
         for i in range(145, 191, 1):
             if i == height:
                 h['ht' + str(i)] += 1
         if height >= 191:
             h['ht' + str(191)] += 1
     mongo_height_stat = mongo_db['heightstat']
     for i in h:
         mongo_height_stat.update({'id': i}, {
             "height": i.replace("ht", ""),
             "value": h[i]
         },
                                  upsert=True)
Exemplo n.º 2
0
 def weight_statistic(self):
     userData = mongo_collection.find()
     w = {'wt0': 0}
     for i in range(34, 62, 1):
         w['wt' + str(i)] = 0
     for item in userData:
         try:
             weight = float(item["bodyweight"].replace('KG', ''))
         except ValueError:
             weight = 0
             w['wt0'] += 1
         if weight <= 34:
             w['wt' + str(34)] += 1
         for i in range(35, 60, 1):
             if i == weight:
                 w['wt' + str(i)] += 1
         if weight >= 61:
             w['wt' + str(61)] += 1
     mongo_weight_stat = mongo_db['weightstat']
     for i in w:
         mongo_weight_stat.update({'id': i}, {
             "weight": i.replace("wt", ""),
             "value": w[i]
         },
                                  upsert=True)
Exemplo n.º 3
0
 def sanwei_statistic(self):
     mongo_sanwei_stat = mongo_db['sanweistat']
     userData = mongo_collection.find()
     for item in userData:
         myItem = re.findall("(\d+)-(\d+)-(\d+)", item['sanwei'])
         if myItem != None and len(myItem) >= 1:
             sanwei = myItem[0]
             chest=sanwei[0]
             waist=sanwei[1]
             buttock=sanwei[2]
             #待完成
         print(myItem)
Exemplo n.º 4
0
 def sanwei_statistic(self):
     mongo_sanwei_stat = mongo_db['sanweistat']
     userData = mongo_collection.find()
     for item in userData:
         myItem = re.findall("(\d+)-(\d+)-(\d+)", item['sanwei'])
         if myItem != None and len(myItem) >= 1:
             sanwei = myItem[0]
             chest = sanwei[0]
             waist = sanwei[1]
             buttock = sanwei[2]
             #待完成
         print(myItem)
Exemplo n.º 5
0
    def birthday_statistic(self):
        import time
        mongo_birthday_stat = mongo_db['birthdaystat']
        userData = mongo_collection.find()
        birthdayCot = {"Aries": 0, "Taurus": 0, "Gemini": 0, "Cancer": 0, "Leo": 0, "Virgo": 0,
                       "Libra": 0, "Scorpio": 0, "Sagittarius": 0, "Capricornus": 0, "Aquarius": 0, "Pisces": 0}
        for item in userData:
            myItem = re.findall("(\d+)月(\d+)日", item['birthday'])
            if myItem != None and len(myItem) >= 1:
                birthday = myItem[0]
                # 按星座统计
                t = (1990, int(birthday[0]), int(birthday[1]), 0, 0, 0, 1, 48, 0)
                secs = time.mktime(t)
                if secs >= time.mktime((1990, 3, 21, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 4, 19, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Aries"] += 1
                elif secs >= time.mktime((1990, 4, 20, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 5, 20, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Taurus"] += 1
                elif secs >= time.mktime((1990, 5, 21, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 6, 21, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Gemini"] += 1
                elif secs >= time.mktime((1990, 6, 22, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 7, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Cancer"] += 1
                elif secs >= time.mktime((1990, 7, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 8, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Leo"] += 1
                elif secs >= time.mktime((1990, 8, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 9, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Virgo"] += 1
                elif secs >= time.mktime((1990, 9, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 10, 23, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Libra"] += 1
                elif secs >= time.mktime((1990, 10, 24, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 11, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Scorpio"] += 1
                elif secs >= time.mktime((1990, 11, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 12, 21, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Sagittarius"] += 1
                elif secs >= time.mktime((1990, 12, 21, 0, 0, 0, 1, 48, 0)) or secs <= time.mktime(
                        (1990, 1, 19, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Capricornus"] += 1
                elif secs >= time.mktime((1990, 1, 20, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 2, 18, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Aquarius"] += 1
                elif secs >= time.mktime((1990, 2, 19, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 3, 20, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Pisces"] += 1

        for i in birthdayCot:
            mongo_birthday_stat.update({'id': i}, {"blood": i, "value": birthdayCot[i]}, upsert=True)
Exemplo n.º 6
0
def load_data():
    """从mongo导入数据"""
    data = []
    for user in mongo_collection.find({"appearance": {"$exists": True},
                                       "satisfy": {"$exists": True}}):
        data.append([user.get('appearance', 0),
                     user.get('age', u'0'),
                     user.get('height', u'0'),
                     SALARY.get(user.get('salary', u'0'), u'--'),
                     EDUCATION.get(user.get('education', u'0'), u'--'),
                     SATISFY[user['satisfy']]])
    labels = [u'颜值', u'年龄', u'身高', u'工资', u'学历']
    return data, labels
Exemplo n.º 7
0
 def blood_statistic(self):
     userData = mongo_collection.find()
     bloodAll = ["A", "B", "AB", "O"]
     bloodCot = {"A": 0, "B": 0, "AB": 0, "O": 0, "other": 0}
     for item in userData:
         blood = item["blood"].replace('型', '')
         if blood == "":
             bloodCot["other"] += 1
         else:
             for item in bloodAll:
                 if blood == item:
                     bloodCot[item] += 1
     mongo_blood_stat = mongo_db['bloodstat']
     for i in bloodCot:
         mongo_blood_stat.update({'id': i}, {"blood": i, "value": bloodCot[i]}, upsert=True)
Exemplo n.º 8
0
 def blood_statistic(self):
     userData = mongo_collection.find()
     bloodAll = ["A", "B", "AB", "O"]
     bloodCot = {"A": 0, "B": 0, "AB": 0, "O": 0, "other": 0}
     for item in userData:
         blood = item["blood"].replace('型', '')
         if blood == "":
             bloodCot["other"] += 1
         else:
             for item in bloodAll:
                 if blood == item:
                     bloodCot[item] += 1
     mongo_blood_stat = mongo_db['bloodstat']
     for i in bloodCot:
         mongo_blood_stat.update({'id': i}, {
             "blood": i,
             "value": bloodCot[i]
         },
                                 upsert=True)
Exemplo n.º 9
0
 def weight_statistic(self):
     userData = mongo_collection.find()
     w = {'wt0': 0}
     for i in range(34, 62, 1):
         w['wt' + str(i)] = 0
     for item in userData:
         try:
             weight = float(item["bodyweight"].replace('KG', ''))
         except ValueError:
             weight = 0
             w['wt0'] += 1
         if weight <= 34:
             w['wt' + str(34)] += 1
         for i in range(35, 60, 1):
             if i == weight:
                 w['wt' + str(i)] += 1
         if weight >= 61:
             w['wt' + str(61)] += 1
     mongo_weight_stat = mongo_db['weightstat']
     for i in w:
         mongo_weight_stat.update({'id': i}, {"weight": i.replace("wt", ""), "value": w[i]}, upsert=True)
Exemplo n.º 10
0
 def height_statistic(self):
     userData = mongo_collection.find()
     h = {'ht0': 0}
     for i in range(144, 192, 1):
         h['ht' + str(i)] = 0
     for item in userData:
         try:
             height = float(item["height"])
         except ValueError:
             height = 0
             h['ht0'] += 1
         if height <= 144:
             h['ht' + str(144)] += 1
         for i in range(145, 191, 1):
             if i == height:
                 h['ht' + str(i)] += 1
         if height >= 191:
             h['ht' + str(191)] += 1
     mongo_height_stat = mongo_db['heightstat']
     for i in h:
         mongo_height_stat.update({'id': i}, {"height": i.replace("ht", ""), "value": h[i]}, upsert=True)
Exemplo n.º 11
0
def load_data():
    """从mongo导入数据"""
    data = []
    for user in mongo_collection.find({
            "appearance": {
                "$exists": True
            },
            "satisfy": {
                "$exists": True
            }
    }):
        data.append([
            user.get('appearance', 0),
            user.get('age', u'0'),
            user.get('height', u'0'),
            SALARY.get(user.get('salary', u'0'), u'--'),
            EDUCATION.get(user.get('education', u'0'), u'--'),
            SATISFY[user['satisfy']]
        ])
    labels = [u'颜值', u'年龄', u'身高', u'工资', u'学历']
    return data, labels
Exemplo n.º 12
0
    def birthday_statistic(self):
        import time
        mongo_birthday_stat = mongo_db['birthdaystat']
        userData = mongo_collection.find()
        birthdayCot = {
            "Aries": 0,
            "Taurus": 0,
            "Gemini": 0,
            "Cancer": 0,
            "Leo": 0,
            "Virgo": 0,
            "Libra": 0,
            "Scorpio": 0,
            "Sagittarius": 0,
            "Capricornus": 0,
            "Aquarius": 0,
            "Pisces": 0
        }
        for item in userData:
            myItem = re.findall("(\d+)月(\d+)日", item['birthday'])
            if myItem != None and len(myItem) >= 1:
                birthday = myItem[0]
                # 按星座统计
                t = (1990, int(birthday[0]), int(birthday[1]), 0, 0, 0, 1, 48,
                     0)
                secs = time.mktime(t)
                if secs >= time.mktime(
                    (1990, 3, 21, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 4, 19, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Aries"] += 1
                elif secs >= time.mktime(
                    (1990, 4, 20, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 5, 20, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Taurus"] += 1
                elif secs >= time.mktime(
                    (1990, 5, 21, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 6, 21, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Gemini"] += 1
                elif secs >= time.mktime(
                    (1990, 6, 22, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 7, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Cancer"] += 1
                elif secs >= time.mktime(
                    (1990, 7, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 8, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Leo"] += 1
                elif secs >= time.mktime(
                    (1990, 8, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 9, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Virgo"] += 1
                elif secs >= time.mktime(
                    (1990, 9, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 10, 23, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Libra"] += 1
                elif secs >= time.mktime(
                    (1990, 10, 24, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 11, 22, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Scorpio"] += 1
                elif secs >= time.mktime(
                    (1990, 11, 23, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 12, 21, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Sagittarius"] += 1
                elif secs >= time.mktime(
                    (1990, 12, 21, 0, 0, 0, 1, 48, 0)) or secs <= time.mktime(
                        (1990, 1, 19, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Capricornus"] += 1
                elif secs >= time.mktime(
                    (1990, 1, 20, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 2, 18, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Aquarius"] += 1
                elif secs >= time.mktime(
                    (1990, 2, 19, 0, 0, 0, 1, 48, 0)) and secs <= time.mktime(
                        (1990, 3, 20, 0, 0, 0, 1, 48, 0)):
                    birthdayCot["Pisces"] += 1

        for i in birthdayCot:
            mongo_birthday_stat.update({'id': i}, {
                "blood": i,
                "value": birthdayCot[i]
            },
                                       upsert=True)