First of all i'm sorry i'm not good at English. but i'll do my best exaplain what i faced problem. if you help me i will very Thank you.
i want make a new dataframe using by another dataframe
for example
month product_no sale_price quantity sale_rate
6 a1 100 2 10%
6 a2 200 1 20%
6 a3 150 2 30%
6 a4 50 4 0%
7 a1 100 1 0%
7 a2 200 3 20%
8 a3 150 4 30%
8 a4 50 2 50%
i want make like this. using for and if function.
month 6 7 8
sale unique_product quantity 3 1 2
sale quantity 5 3 6
gmv 700 600 700
non_sale unique_product quantity 4 1 0
sale quantity 1 1 0
gmv 200 100 0
i tried like this. but it's not working
sale = []
non_sale = []
months = [6,7,8,9,10,11,12]
for i in months :
if made_data[(made_data.month == i) & (made_data.sale_rate== 0)] :
non_sale.append(len(made_data[(made_data.month == i) & (made_data.sale_rate == 0)].product_no.unique()))
elif made_data[(made_data.month== i) & (made_data.sale_rate!= 0)] :
sale.append(len(made_data[(made_data.month== i) & (made_data.sale_rate== 0)].product_no.unique()))
Aucun commentaire:
Enregistrer un commentaire