Problems related to Python+Mongodb and Pandas data Statistics

def getuser():
    users = user.find({
        "totalRecharge": {"$gt": 0},
        "$or": [
            {"recharge.from": "weixin"},
            {"recharge.from": "alipay"},
            {"recharge.from": {"$ne": "jCode"}},
            {"recharge.from": {"$ne": "regCoupon"}}
        ]
    })
    data = [u for u in users]
    frame = pd.DataFrame(data, columns=["phone", "balance", "totalRecharge"])
    print(frame[(frame["balance"]/100 > 100) & (frame["totalRecharge"]/100 > 1000)].count())
    return

recently re-studied Python for data statistics, the database is MongoDB, recently found that some Pandas and Pymongo aggregation pipeline function is similar, pandas is not proficient basically while writing to the Internet to find some methods.

  1. the proportion of int fields in the problem database is 100. For example, the balance field 1 yuan = 100. How to divide by 100 when building a dataframe?
  2. and groupbycut, why are there so few articles on these methods in China?
  3. A bunch of getting started, must-see, and XX methods Nima are all copied documents back and forth, but there is very little practical information for their own use of summary or use?

from the amount of code, I still prefer Pandas! Ask the veterans to show us the way.

Dec.23,2021
Menu