Guest User

Untitled

a guest
Dec 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. def Problem(file_name1,file_name2,file_name3):
  2. import pandas as pd
  3. import numpy as np
  4. from IPython.display import display, HTML
  5. product_category=pd.read_csv(file_name1,sep=",");product_category.head()
  6. olist_products=pd.read_csv(file_name2,sep=",");olist_products.head()
  7. olist_order=pd.read_csv(file_name3,sep=",");olist_order.head()
  8. data=pd.merge(pd.merge(product_category,olist_products),olist_order)
  9. data["freight_percent"]=(data["freight_value"]/(data["freight_value"]+data["price"]))*100
  10. Data_Categorized=data.pivot_table(index="product_category_name_english",values=(["freight_percent"]),aggfunc="mean")
  11. top_10=Data_Categorized.sort_values("freight_percent",ascending=False)[:10]
  12. top_10=top_10.reset_index()
  13. top_10.index=top_10.index+1
  14. bottom_10=Data_Categorized.sort_values("freight_percent")[:10]
  15. bottom_10=bottom_10.reset_index()
  16. bottom_10.index=bottom_10.index+1
  17. result = pd.concat([top_10, bottom_10], axis=1, sort=False)
  18. print("tt33[94m33[1mTOP 10 tttt BOTTOM 10")
  19. display (result)
  20.  
  21. Problem("product_category_name_translation.csv","olist_products_dataset.csv","olist_order_items_dataset.csv")
Add Comment
Please, Sign In to add comment