import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objs as go
import plotly.offline as iplot
pwd
'/Users/mac'
ls
Sales Data Analysis.ipynb @github.com/ Applications/ Betty/ Data Science Week 2 Case Study.ipynb Data clearing with python.ipynb Desktop/ Diabetic Data.ipynb Documents/ Downloads/ Example.ipynb Library/ Matplotlib Class.ipynb Movies/ Music/ PANDAS Data Frames.ipynb Pictures/ Public/ PycharmProjects/ Seaborn libary.ipynb Untitled.ipynb Untitled1.ipynb Untitled2.ipynb Untitled3.ipynb Untitled4.ipynb Untitled5.ipynb Untitled6.ipynb Week 1 Case Study Managing Student Information .ipynb alx-low_level_programming/ alx-low_level_programming-1/ alx-pre_course/ alx-system_engineering-devops/ alx-zero_day/ anaconda3/ bash/ c/ cryptex/ figure2.png js/ pandas intro.ipynb pandas.ipynb testwork.ipynb zero_day/
cd desktop
/Users/mac/Desktop
ls
000DF646-332C-4B8E-8CF1-0E0891E48743.MP4 0e663a72-2ce6-4df5-a1ab-1230f421d46d.MP4 10-check_cycle.c 10-linked_lists.c 10fd4c9f-75ea-4484-abfe-ab433840f0aa.JPG 142aaef7-c25d-4645-be6a-7b00f0c23ee6.JPG 1c930d9e-542d-4d98-9bdd-482671ffc878.JPG 2129c1c1-3b61-41a2-bf13-7fbe5a7127b4.JPG 2767fe65-1fa4-47f3-818e-94f179fd1f53.JPG 2D35F7B0-0587-476E-9240-2C54EF12E34C.JPG 3-print_alphabt.py 364c8528-7c86-48e7-a4f6-50f0eaf23242.JPG 3f5d533b-9fce-4ea8-ada1-989be8513652.JPG 43a7dac6-00c0-40b5-afd1-1b5ddec7929f.JPG 450dc9d1-4c2f-404c-8313-82573120b61e.JPG 46203242-b471-4f7e-808e-f32e425f0edd.JPG 7d7d185e-93f9-415c-b59a-751aa2ffaff0.JPG 7ec45444-f0a1-4ab4-9a57-705ab20aad26.JPG 924dfd31-4380-4891-b14d-4998650c9315.JPG AMP Access Account.pdf C FILES/ House_of_the_Dragon_S01E05_480p_WEB-DL_RMTeam.mkv IMG_4685.HEIC IMG_4798.MOV IMG_4799.MOV IMG_4800.MOV IMG_4838.MOV IMG_4839.MOV IMG_4840.MOV IMG_4848.MOV IMG_4849.MOV IMG_4850.MOV IMG_4851.MOV IMG_4852.MOV IMG_4853.MOV IMG_4930.HEIC IMG_4931.HEIC IMG_4932.HEIC IMG_4933.HEIC IMG_4934.HEIC IMG_4935.HEIC IMG_4936.HEIC IMG_4937.HEIC IMG_4938.HEIC IMG_4939.HEIC IMG_4940.HEIC IMG_4941.HEIC IMG_4942.MOV IMG_4943.HEIC IMG_4944.HEIC IMG_4945.HEIC IMG_4946.HEIC IMG_4947.HEIC IMG_4948.HEIC IMG_4949.HEIC IMG_4950.HEIC IMG_4951.HEIC IMG_4952.HEIC IMG_4953.HEIC IMG_4954.HEIC IMG_4955.HEIC IMG_4956.HEIC IMG_4957.HEIC IMG_4958.HEIC IMG_4959.HEIC IMG_4960.HEIC IMG_4961.HEIC IMG_4962.HEIC IMG_4963.HEIC IMG_4964.HEIC IMG_4965.HEIC IMG_4966.HEIC IMG_4967.HEIC IMG_4968.HEIC IMG_4969.HEIC IMG_4970.HEIC IMG_4971.HEIC IMG_4972.HEIC IMG_4973.HEIC IMG_4974.HEIC IMG_4975.HEIC IMG_4976.HEIC IMG_4977.HEIC IMG_4978.HEIC IMG_4979.HEIC IMG_4980.HEIC IMG_4981.HEIC IMG_4982.HEIC IMG_4983.HEIC IMG_4984.HEIC IMG_4985.HEIC IMG_4986.HEIC IMG_4987.HEIC IMG_4988.HEIC IMG_4989.HEIC IMG_4990.HEIC IMG_4991.HEIC IMG_4992.HEIC IMG_4993.HEIC IMG_4994.HEIC IMG_4995.HEIC IMG_4996.HEIC IMG_4997.HEIC IMG_4998.HEIC IMG_4999.HEIC IMG_5001.HEIC IMG_5002.HEIC IMG_5003.HEIC IMG_5004.HEIC IMG_5005.HEIC IMG_5006.HEIC IMG_5007.HEIC IMG_5008.HEIC IMG_5009.HEIC IMG_5010.HEIC IMG_5012.HEIC IMG_5013.HEIC IMG_5014.HEIC IMG_5015.HEIC InterimStmt_20221230.pdf Motherland_Fort_Salem_S03E01_480p_WEB-DL_RMTeam.mkv OnlineTrade 2/ Real estate/ Sales Data.csv Screen Shot 2022-10-03 at 6.47.46 AM.png The.Lord.of.the.Rings.The.Rings.of.Power.S01E03.(NKIRI.COM).mkv [Waploaded]_farming-2019.mp4 ad8cbe3e-aeb3-4dbc-9baa-120bced58b11.JPG beam/ bill.pdf bitcoin.jpeg blog-details.html* cf2dcd66-a2aa-4321-b11d-13d5e5011e9b.JPG d562e97e-209f-44ae-99b8-972350ac766c.JPG diabetes.csv e0bb684a-4f2f-463a-b309-97eec0a0d33b.JPG e46796bc-b52e-46d8-8e11-ccb238776bed.JPG eae747ac-4183-45bd-82b1-27f525b3710b.JPG eede4b83-4403-44a0-9420-5cd53afbcfff.JPG faq.html* favicon.ico ff135690-c714-488c-9f90-1bcf1681b2b1.JPG ffdade24-2654-4da4-ae91-3652dc149c1b.JPG how-it-works.html* image (1).jpg image.jpg logo-dark.png logo.JPG logo.png privacy-policy.html* service-details.html* terms.html* theme/ titanic.csv wallpaperflare.com_wallpaper (1).jpg ‹ Fastlane Logistics — WordPress.pdf
cd
/Users/mac
cd documents
/Users/mac/Documents
ls
GitHub/ Nicepage/ WORDPRESS BTC/ My Tableau Repository/ Nicepage Templates/ archbb/ New/ PlaybackEventStreams/ ikkuna-master/ New.zip Sales Data.csv
df = pd.read_csv('Sales Data.csv')
df.head()
| Unnamed: 0 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Hour | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 295665 | Macbook Pro Laptop | 1 | 1700.00 | 2019-12-30 00:01:00 | 136 Church St, New York City, NY 10001 | 12 | 1700.00 | New York City | 0 |
| 1 | 1 | 295666 | LG Washing Machine | 1 | 600.00 | 2019-12-29 07:03:00 | 562 2nd St, New York City, NY 10001 | 12 | 600.00 | New York City | 7 |
| 2 | 2 | 295667 | USB-C Charging Cable | 1 | 11.95 | 2019-12-12 18:21:00 | 277 Main St, New York City, NY 10001 | 12 | 11.95 | New York City | 18 |
| 3 | 3 | 295668 | 27in FHD Monitor | 1 | 149.99 | 2019-12-22 15:13:00 | 410 6th St, San Francisco, CA 94016 | 12 | 149.99 | San Francisco | 15 |
| 4 | 4 | 295669 | USB-C Charging Cable | 1 | 11.95 | 2019-12-18 12:38:00 | 43 Hill St, Atlanta, GA 30301 | 12 | 11.95 | Atlanta | 12 |
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 185950 entries, 0 to 185949 Data columns (total 11 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Unnamed: 0 185950 non-null int64 1 Order ID 185950 non-null int64 2 Product 185950 non-null object 3 Quantity Ordered 185950 non-null int64 4 Price Each 185950 non-null float64 5 Order Date 185950 non-null object 6 Purchase Address 185950 non-null object 7 Month 185950 non-null int64 8 Sales 185950 non-null float64 9 City 185950 non-null object 10 Hour 185950 non-null int64 dtypes: float64(2), int64(5), object(4) memory usage: 15.6+ MB
df.head()
| Unnamed: 0 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Hour | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 295665 | Macbook Pro Laptop | 1 | 1700.00 | 2019-12-30 00:01:00 | 136 Church St, New York City, NY 10001 | 12 | 1700.00 | New York City | 0 |
| 1 | 1 | 295666 | LG Washing Machine | 1 | 600.00 | 2019-12-29 07:03:00 | 562 2nd St, New York City, NY 10001 | 12 | 600.00 | New York City | 7 |
| 2 | 2 | 295667 | USB-C Charging Cable | 1 | 11.95 | 2019-12-12 18:21:00 | 277 Main St, New York City, NY 10001 | 12 | 11.95 | New York City | 18 |
| 3 | 3 | 295668 | 27in FHD Monitor | 1 | 149.99 | 2019-12-22 15:13:00 | 410 6th St, San Francisco, CA 94016 | 12 | 149.99 | San Francisco | 15 |
| 4 | 4 | 295669 | USB-C Charging Cable | 1 | 11.95 | 2019-12-18 12:38:00 | 43 Hill St, Atlanta, GA 30301 | 12 | 11.95 | Atlanta | 12 |
df.isnull().sum()
Unnamed: 0 0 Order ID 0 Product 0 Quantity Ordered 0 Price Each 0 Order Date 0 Purchase Address 0 Month 0 Sales 0 City 0 Hour 0 dtype: int64
df =df.dropna(how='all')
df.shape
(185950, 11)
'04/19/19 08.46'.split('/')[0]
'04'
def Month(x):
return x .split('/')[0]
df['Month'] = df ['Order Date']. apply(Month)
df.dtypes
Unnamed: 0 int64 Order ID int64 Product object Quantity Ordered int64 Price Each float64 Order Date object Purchase Address object Month object Sales float64 City object Hour int64 dtype: object
df['Month'].unique()
array(['2019-12-30 00:01:00', '2019-12-29 07:03:00',
'2019-12-12 18:21:00', ..., '2019-06-09 22:07:00',
'2019-06-26 18:35:00', '2019-06-25 14:33:00'], dtype=object)
filter=df['Month']=='Order Date'
len (df[~filter])
185950
df=df[~filter]
df.shape
(185950, 11)
df.head()
| Unnamed: 0 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Hour | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 295665 | Macbook Pro Laptop | 1 | 1700.00 | 2019-12-30 00:01:00 | 136 Church St, New York City, NY 10001 | 2019-12-30 00:01:00 | 1700.00 | New York City | 0 |
| 1 | 1 | 295666 | LG Washing Machine | 1 | 600.00 | 2019-12-29 07:03:00 | 562 2nd St, New York City, NY 10001 | 2019-12-29 07:03:00 | 600.00 | New York City | 7 |
| 2 | 2 | 295667 | USB-C Charging Cable | 1 | 11.95 | 2019-12-12 18:21:00 | 277 Main St, New York City, NY 10001 | 2019-12-12 18:21:00 | 11.95 | New York City | 18 |
| 3 | 3 | 295668 | 27in FHD Monitor | 1 | 149.99 | 2019-12-22 15:13:00 | 410 6th St, San Francisco, CA 94016 | 2019-12-22 15:13:00 | 149.99 | San Francisco | 15 |
| 4 | 4 | 295669 | USB-C Charging Cable | 1 | 11.95 | 2019-12-18 12:38:00 | 43 Hill St, Atlanta, GA 30301 | 2019-12-18 12:38:00 | 11.95 | Atlanta | 12 |
df["Month"]
0 2019-12-30 00:01:00
1 2019-12-29 07:03:00
2 2019-12-12 18:21:00
3 2019-12-22 15:13:00
4 2019-12-18 12:38:00
...
185945 2019-06-07 19:02:00
185946 2019-06-01 19:29:00
185947 2019-06-22 18:57:00
185948 2019-06-26 18:35:00
185949 2019-06-25 14:33:00
Name: Month, Length: 185950, dtype: object
df.dtypes
Unnamed: 0 int64 Order ID int64 Product object Quantity Ordered int64 Price Each float64 Order Date object Purchase Address object Month object Sales float64 City object Hour int64 dtype: object
df['Price Each']=df['Price Each'].astype(float)
df['Quantity Ordered']=df['Quantity Ordered'].astype(int)
df['sales']=df['Quantity Ordered']*df['Price Each']
df.head(5)
| Unnamed: 0 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Hour | sales | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 295665 | Macbook Pro Laptop | 1 | 1700.00 | 2019-12-30 00:01:00 | 136 Church St, New York City, NY 10001 | 2019-12-30 00:01:00 | 1700.00 | New York City | 0 | 1700.00 |
| 1 | 1 | 295666 | LG Washing Machine | 1 | 600.00 | 2019-12-29 07:03:00 | 562 2nd St, New York City, NY 10001 | 2019-12-29 07:03:00 | 600.00 | New York City | 7 | 600.00 |
| 2 | 2 | 295667 | USB-C Charging Cable | 1 | 11.95 | 2019-12-12 18:21:00 | 277 Main St, New York City, NY 10001 | 2019-12-12 18:21:00 | 11.95 | New York City | 18 | 11.95 |
| 3 | 3 | 295668 | 27in FHD Monitor | 1 | 149.99 | 2019-12-22 15:13:00 | 410 6th St, San Francisco, CA 94016 | 2019-12-22 15:13:00 | 149.99 | San Francisco | 15 | 149.99 |
| 4 | 4 | 295669 | USB-C Charging Cable | 1 | 11.95 | 2019-12-18 12:38:00 | 43 Hill St, Atlanta, GA 30301 | 2019-12-18 12:38:00 | 11.95 | Atlanta | 12 | 11.95 |
df.groupby('Month')['sales'].sum()
Month
2019-01-01 03:07:00 11.99
2019-01-01 03:40:00 11.95
2019-01-01 04:56:00 150.00
2019-01-01 05:53:00 2.99
2019-01-01 06:03:00 23.90
...
2020-01-01 04:06:00 149.99
2020-01-01 04:13:00 2.99
2020-01-01 04:21:00 11.95
2020-01-01 04:54:00 99.99
2020-01-01 05:13:00 114.94
Name: sales, Length: 142395, dtype: float64
'917 1st St,Dallas, TX75001'.split(',')[1]
'Dallas'
def city(x):
return x.split(',')[1]
df['city'] =df['Purchase Address'].apply(city)
df.groupby('city')['city'].count()
city Atlanta 14881 Austin 9905 Boston 19934 Dallas 14820 Los Angeles 29605 New York City 24876 Portland 12465 San Francisco 44732 Seattle 14732 Name: city, dtype: int64
plt.bar(df.groupby('city')['city'].count().index,df.groupby('city')['city'].count())
plt.xticks(rotation='vertical')
plt.ylabel('received orders')
plt.xlabel('city names')
plt.show()
# df['Order Date'][0].dtype
df['Hour']=pd.to_datetime(df['Order Date']).dt.hour
keys = []
hour = []
for key,hour_df in df.groupby('Hour'):
keys.append(key)
hour.append(len(hour_df))
plt.grid()
plt.plot(keys,hour)
[<matplotlib.lines.Line2D at 0x1503df4d0>]
df.groupby('Product')['Quantity Ordered'].sum().plot(kind='bar')
<Axes: xlabel='Product'>
df.groupby('Product')['Price Each'].mean()
Product 20in Monitor 109.99 27in 4K Gaming Monitor 389.99 27in FHD Monitor 149.99 34in Ultrawide Monitor 379.99 AA Batteries (4-pack) 3.84 AAA Batteries (4-pack) 2.99 Apple Airpods Headphones 150.00 Bose SoundSport Headphones 99.99 Flatscreen TV 300.00 Google Phone 600.00 LG Dryer 600.00 LG Washing Machine 600.00 Lightning Charging Cable 14.95 Macbook Pro Laptop 1700.00 ThinkPad Laptop 999.99 USB-C Charging Cable 11.95 Vareebadd Phone 400.00 Wired Headphones 11.99 iPhone 700.00 Name: Price Each, dtype: float64
products=df.groupby('Product')['Quantity Ordered'].sum().index
quantity=df.groupby('Product')['Quantity Ordered'].sum()
prices=df.groupby('Product')['Price Each'].mean()
plt.figure(figsize=(40,24))
fig,ax1=plt.subplots()
ax2=ax1.twinx()
ax1.bar(products,quantity,color='g')
ax2.plot(products,prices,'b-')
ax1.set_xticklabels(products,rotation='vertical',size=8)
/var/folders/7v/92s_wyw97qb555bhcykb9hvw0000gn/T/ipykernel_10498/3467980537.py:6: UserWarning: FixedFormatter should only be used together with FixedLocator
[Text(0, 0, '20in Monitor'), Text(1, 0, '27in 4K Gaming Monitor'), Text(2, 0, '27in FHD Monitor'), Text(3, 0, '34in Ultrawide Monitor'), Text(4, 0, 'AA Batteries (4-pack)'), Text(5, 0, 'AAA Batteries (4-pack)'), Text(6, 0, 'Apple Airpods Headphones'), Text(7, 0, 'Bose SoundSport Headphones'), Text(8, 0, 'Flatscreen TV'), Text(9, 0, 'Google Phone'), Text(10, 0, 'LG Dryer'), Text(11, 0, 'LG Washing Machine'), Text(12, 0, 'Lightning Charging Cable'), Text(13, 0, 'Macbook Pro Laptop'), Text(14, 0, 'ThinkPad Laptop'), Text(15, 0, 'USB-C Charging Cable'), Text(16, 0, 'Vareebadd Phone'), Text(17, 0, 'Wired Headphones'), Text(18, 0, 'iPhone')]
<Figure size 4000x2400 with 0 Axes>
What products are most often sold together? note: keep orders that have same order Id are sold mostly together
db=df[df['Order ID'].duplicated(keep=False)]
db.head(20)
| Unnamed: 0 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Hour | sales | city | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 16 | 16 | 295681 | Google Phone | 1 | 600.00 | 2019-12-25 12:37:00 | 79 Elm St, Boston, MA 02215 | 2019-12-25 12:37:00 | 600.00 | Boston | 12 | 600.00 | Boston |
| 17 | 17 | 295681 | USB-C Charging Cable | 1 | 11.95 | 2019-12-25 12:37:00 | 79 Elm St, Boston, MA 02215 | 2019-12-25 12:37:00 | 11.95 | Boston | 12 | 11.95 | Boston |
| 18 | 18 | 295681 | Bose SoundSport Headphones | 1 | 99.99 | 2019-12-25 12:37:00 | 79 Elm St, Boston, MA 02215 | 2019-12-25 12:37:00 | 99.99 | Boston | 12 | 99.99 | Boston |
| 19 | 19 | 295681 | Wired Headphones | 1 | 11.99 | 2019-12-25 12:37:00 | 79 Elm St, Boston, MA 02215 | 2019-12-25 12:37:00 | 11.99 | Boston | 12 | 11.99 | Boston |
| 36 | 36 | 295698 | Vareebadd Phone | 1 | 400.00 | 2019-12-13 14:32:00 | 175 1st St, New York City, NY 10001 | 2019-12-13 14:32:00 | 400.00 | New York City | 14 | 400.00 | New York City |
| 37 | 37 | 295698 | USB-C Charging Cable | 2 | 11.95 | 2019-12-13 14:32:00 | 175 1st St, New York City, NY 10001 | 2019-12-13 14:32:00 | 23.90 | New York City | 14 | 23.90 | New York City |
| 42 | 42 | 295703 | AA Batteries (4-pack) | 1 | 3.84 | 2019-12-17 12:27:00 | 502 Jefferson St, Austin, TX 73301 | 2019-12-17 12:27:00 | 3.84 | Austin | 12 | 3.84 | Austin |
| 43 | 43 | 295703 | Bose SoundSport Headphones | 1 | 99.99 | 2019-12-17 12:27:00 | 502 Jefferson St, Austin, TX 73301 | 2019-12-17 12:27:00 | 99.99 | Austin | 12 | 99.99 | Austin |
| 66 | 66 | 295726 | iPhone | 1 | 700.00 | 2019-12-25 14:49:00 | 203 Lakeview St, Boston, MA 02215 | 2019-12-25 14:49:00 | 700.00 | Boston | 14 | 700.00 | Boston |
| 67 | 67 | 295726 | Lightning Charging Cable | 1 | 14.95 | 2019-12-25 14:49:00 | 203 Lakeview St, Boston, MA 02215 | 2019-12-25 14:49:00 | 14.95 | Boston | 14 | 14.95 | Boston |
| 76 | 76 | 295735 | iPhone | 1 | 700.00 | 2019-12-22 18:25:00 | 374 Lincoln St, New York City, NY 10001 | 2019-12-22 18:25:00 | 700.00 | New York City | 18 | 700.00 | New York City |
| 77 | 77 | 295735 | Apple Airpods Headphones | 1 | 150.00 | 2019-12-22 18:25:00 | 374 Lincoln St, New York City, NY 10001 | 2019-12-22 18:25:00 | 150.00 | New York City | 18 | 150.00 | New York City |
| 78 | 78 | 295735 | Wired Headphones | 1 | 11.99 | 2019-12-22 18:25:00 | 374 Lincoln St, New York City, NY 10001 | 2019-12-22 18:25:00 | 11.99 | New York City | 18 | 11.99 | New York City |
| 80 | 80 | 295737 | iPhone | 1 | 700.00 | 2019-12-19 08:51:00 | 966 10th St, Atlanta, GA 30301 | 2019-12-19 08:51:00 | 700.00 | Atlanta | 8 | 700.00 | Atlanta |
| 81 | 81 | 295737 | Lightning Charging Cable | 1 | 14.95 | 2019-12-19 08:51:00 | 966 10th St, Atlanta, GA 30301 | 2019-12-19 08:51:00 | 14.95 | Atlanta | 8 | 14.95 | Atlanta |
| 97 | 97 | 295753 | 34in Ultrawide Monitor | 1 | 379.99 | 2019-12-25 06:26:00 | 365 Washington St, Dallas, TX 75001 | 2019-12-25 06:26:00 | 379.99 | Dallas | 6 | 379.99 | Dallas |
| 98 | 98 | 295753 | Lightning Charging Cable | 1 | 14.95 | 2019-12-25 06:26:00 | 365 Washington St, Dallas, TX 75001 | 2019-12-25 06:26:00 | 14.95 | Dallas | 6 | 14.95 | Dallas |
| 104 | 104 | 295759 | Bose SoundSport Headphones | 1 | 99.99 | 2019-12-25 06:53:00 | 15 Pine St, New York City, NY 10001 | 2019-12-25 06:53:00 | 99.99 | New York City | 6 | 99.99 | New York City |
| 105 | 105 | 295759 | Wired Headphones | 1 | 11.99 | 2019-12-25 06:53:00 | 15 Pine St, New York City, NY 10001 | 2019-12-25 06:53:00 | 11.99 | New York City | 6 | 11.99 | New York City |
| 129 | 129 | 295783 | Vareebadd Phone | 1 | 400.00 | 2019-12-06 12:41:00 | 87 5th St, San Francisco, CA 94016 | 2019-12-06 12:41:00 | 400.00 | San Francisco | 12 | 400.00 | San Francisco |
db['Grouped']=db.groupby('Order ID')['Product'].transform(lambda x: ','.join(x))
/var/folders/7v/92s_wyw97qb555bhcykb9hvw0000gn/T/ipykernel_10498/2681736227.py:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
#lets drop out all duplicates Order ID
db2=db.drop_duplicates(subset=['Order ID'])
db2['Grouped'].value_counts()[0:5].plot.pie()
<Axes: ylabel='Grouped'>
values =db2['Grouped'].value_counts()[0:5]
labels=db['Grouped'].value_counts()[0:5].index
trace=go.Pie(labels=labels, values=values,
hoverinfo='label+percent', textinfo='value',
textfont=dict(size=25),
pull=[0,0,0,0.2,0]
)