fork download
  1. import pandas as pd
  2.  
  3. data={'product':['product_A','product_B','product_C','product_D'],
  4.  
  5. 'quantity':[10,20,30,40],
  6.  
  7. 'sales':[100,200,300,400],
  8.  
  9. 'store':['store1','store2','store3''store4'],
  10.  
  11. 'customer':['customer1','customer2','customer3','customer4']}
  12.  
  13. data = pd.DataFrame(data)
  14.  
  15. print(data)
  16.  
  17. product_sold=data[data['quantity']>0] ['product'].unique()
  18.  
  19. print(product_sold)
  20.  
  21. quantity_sold=data.groupby(['product'])['quantity'].sum().reset_index()
  22.  
  23. print(quantity_sold)
  24.  
  25. quantity_sale_data.groupby(['product']).agg({'quantity': 'sum', 'sales': 'sum'}).reset_index()
  26.  
  27. print(quantity_sale)
  28.  
  29. quantity_store=data.groupby(['product', 'store']).agg({'quantity': 'sum'}).reset_index()
  30.  
  31. print(quantity_store)
  32.  
  33. product_not_sold=data[ data['quantity']==0]['product'].unique()
  34.  
  35. print(product_not_sold)
  36.  
  37. customer_no_purchase=data [data[quantity]==0]['customer'].unique()
  38.  
  39.  
  40. print(customer_no_purchase)
Success #stdin #stdout 0.02s 25760KB
stdin
Standard input is empty
stdout
import pandas as pd

data={'product':['product_A','product_B','product_C','product_D'],

'quantity':[10,20,30,40],

'sales':[100,200,300,400],

'store':['store1','store2','store3''store4'],

'customer':['customer1','customer2','customer3','customer4']}

data = pd.DataFrame(data)

print(data)

product_sold=data[data['quantity']>0] ['product'].unique()

print(product_sold)

quantity_sold=data.groupby(['product'])['quantity'].sum().reset_index()

print(quantity_sold)	

quantity_sale_data.groupby(['product']).agg({'quantity': 'sum', 'sales': 'sum'}).reset_index()

print(quantity_sale)

quantity_store=data.groupby(['product', 'store']).agg({'quantity': 'sum'}).reset_index()

print(quantity_store) 

product_not_sold=data[ data['quantity']==0]['product'].unique()

print(product_not_sold)

customer_no_purchase=data [data[quantity]==0]['customer'].unique()


print(customer_no_purchase)