@niranjan_283 wrote:
I want to different type of aggregations to by columns after grouping based on Certain Columns. i was able to achieve that using the
tempstatecity = customerdata.groupby(["Last_state","Last_city"]) tempstatecity["Customer_ID","Buy_Times","Customer_Value"].agg({"CountOfCustomer":"count","AvgCountOfPurchases":"avg","AvgOfPurchaseValue":"avg"})
but the use of .agg function depreciated recently, how to do different aggregations for different columns?
Recently i have found a way of aggregation but it won’t help me in applying different aggregations for different columns.
tempstatecity = customerdata.groupby(["Last_state","Last_city"]) tempstatecity[["Customer_ID","Buy_Times","Customer_Value"]].agg(["count","sum"])
Output will be like:
But i want to apply different aggregations like count for customer_id and sum for Buy_Times etc…,Any help in achieving this would be very helpful
Posts: 3
Participants: 2