Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Problem(file_name1,file_name2,file_name3):
- import pandas as pd
- import numpy as np
- from IPython.display import display, HTML
- product_category=pd.read_csv(file_name1,sep=",");product_category.head()
- olist_products=pd.read_csv(file_name2,sep=",");olist_products.head()
- olist_order=pd.read_csv(file_name3,sep=",");olist_order.head()
- data=pd.merge(pd.merge(product_category,olist_products),olist_order)
- data["freight_percent"]=(data["freight_value"]/(data["freight_value"]+data["price"]))*100
- Data_Categorized=data.pivot_table(index="product_category_name_english",values=(["freight_percent"]),aggfunc="mean")
- top_10=Data_Categorized.sort_values("freight_percent",ascending=False)[:10]
- top_10=top_10.reset_index()
- top_10.index=top_10.index+1
- bottom_10=Data_Categorized.sort_values("freight_percent")[:10]
- bottom_10=bottom_10.reset_index()
- bottom_10.index=bottom_10.index+1
- result = pd.concat([top_10, bottom_10], axis=1, sort=False)
- print("tt 33[94m 33[1mTOP 10 tttt BOTTOM 10")
- display (result)
- Problem("product_category_name_translation.csv","olist_products_dataset.csv","olist_order_items_dataset.csv")
Add Comment
Please, Sign In to add comment