import pandas as pd
import numpy as np
data = pd.read_csv("sales_data.csv")
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | |
---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 |
1 | NaN | NaN | NaN | NaN | NaN | NaN |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 |
3 | 176560 | Google Phone | 1 | 600 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 |
data.dtypes
Order ID object Product object Quantity Ordered object Price Each object Order Date object Purchase Address object dtype: object
data.shape
(186850, 6)
|As we can see dataset contain 186850 rows, and 6 columns. All the columns are object data type, maybe we need to change data type. we will do it later. Now, there are some null values. In order to get most accurate answers we need to clean null values. Lets check how many null we have.
null = data[data.isnull().any(axis=1)]
null.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | |
---|---|---|---|---|---|---|
1 | NaN | NaN | NaN | NaN | NaN | NaN |
356 | NaN | NaN | NaN | NaN | NaN | NaN |
735 | NaN | NaN | NaN | NaN | NaN | NaN |
1433 | NaN | NaN | NaN | NaN | NaN | NaN |
1553 | NaN | NaN | NaN | NaN | NaN | NaN |
data = data.dropna(how="all")
data.shape
(186305, 6)
|As we can see null values are removed.
To answer the question I need month and sales column. But As we see above data we don't have any column named month or sales. But, from "order date" column we can extract month and sales from quantity ordered and price column. Let's create them.
data['Month'] = data['Order Date'].str[0:2]
data['Month'] = data['Month'].astype('int32')
data.head()
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_3908\4101063803.py in <module> ----> 1 data['Month'] = data['Month'].astype('int32') 2 data.head() ~\anaconda3\lib\site-packages\pandas\core\generic.py in astype(self, dtype, copy, errors) 5910 else: 5911 # else, only a single dtype is given -> 5912 new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors) 5913 return self._constructor(new_data).__finalize__(self, method="astype") 5914 ~\anaconda3\lib\site-packages\pandas\core\internals\managers.py in astype(self, dtype, copy, errors) 417 418 def astype(self: T, dtype, copy: bool = False, errors: str = "raise") -> T: --> 419 return self.apply("astype", dtype=dtype, copy=copy, errors=errors) 420 421 def convert( ~\anaconda3\lib\site-packages\pandas\core\internals\managers.py in apply(self, f, align_keys, ignore_failures, **kwargs) 302 applied = b.apply(f, **kwargs) 303 else: --> 304 applied = getattr(b, f)(**kwargs) 305 except (TypeError, NotImplementedError): 306 if not ignore_failures: ~\anaconda3\lib\site-packages\pandas\core\internals\blocks.py in astype(self, dtype, copy, errors) 578 values = self.values 579 --> 580 new_values = astype_array_safe(values, dtype, copy=copy, errors=errors) 581 582 new_values = maybe_coerce_values(new_values) ~\anaconda3\lib\site-packages\pandas\core\dtypes\cast.py in astype_array_safe(values, dtype, copy, errors) 1290 1291 try: -> 1292 new_values = astype_array(values, dtype, copy=copy) 1293 except (ValueError, TypeError): 1294 # e.g. astype_nansafe can fail on object-dtype of strings ~\anaconda3\lib\site-packages\pandas\core\dtypes\cast.py in astype_array(values, dtype, copy) 1235 1236 else: -> 1237 values = astype_nansafe(values, dtype, copy=copy) 1238 1239 # in pandas we don't store numpy str dtypes, so convert to object ~\anaconda3\lib\site-packages\pandas\core\dtypes\cast.py in astype_nansafe(arr, dtype, copy, skipna) 1152 # work around NumPy brokenness, #1987 1153 if np.issubdtype(dtype.type, np.integer): -> 1154 return lib.astype_intsafe(arr, dtype) 1155 1156 # if we have a datetime/timedelta array of objects ~\anaconda3\lib\site-packages\pandas\_libs\lib.pyx in pandas._libs.lib.astype_intsafe() ValueError: invalid literal for int() with base 10: 'Or'
checkingOr = data[data['Order Date'].str[0:2]=='Or']
checkingOr.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | |
---|---|---|---|---|---|---|---|
519 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Or |
1149 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Or |
1155 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Or |
2878 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Or |
2893 | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Or |
So, Or is coming from Month column. let's change it just by changing equal sign to not equal.
data = data[data['Order Date'].str[0:2]!='Or']
data['Month'] = data['Order Date'].str[0:2]
data['Month'] = data['Month'].astype('int32')
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | |
---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 |
3 | 176560 | Google Phone | 1 | 600 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 |
Alright! month column is created. In the second step I will create Sales column. But, before going ahead lets check data another time:
data.dtypes
Order ID object Product object Quantity Ordered object Price Each object Order Date object Purchase Address object Month int32 dtype: object
As we can see Quantity Orders and Price Each are string value. We can not multiply strings in order to get Sales. So, we need to convert data types first.
data['Quantity Ordered'] = pd.to_numeric(data['Quantity Ordered'])
data['Price Each'] = pd.to_numeric(data['Price Each'])
data.dtypes
Order ID object Product object Quantity Ordered int64 Price Each float64 Order Date object Purchase Address object Month int32 dtype: object
Alright! Data type has been changed to numeric value as int and float. Lets create Sales column.
data['Sales'] = data['Quantity Ordered']*data['Price Each']
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | |
---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 |
Sales column is successfully created. let's, find out the answer of first question.
Monthly_sales = data.groupby('Month').sum().sort_values(by='Sales', ascending=False)
Monthly_sales.head(12)
Quantity Ordered | Price Each | Sales | |
---|---|---|---|
Month | |||
12 | 28114 | 4588415.41 | 4613443.34 |
10 | 22703 | 3715554.83 | 3736726.88 |
4 | 20558 | 3367671.02 | 3390670.24 |
11 | 19798 | 3180600.68 | 3199603.20 |
5 | 18667 | 3135125.13 | 3152606.75 |
3 | 17005 | 2791207.83 | 2807100.38 |
7 | 16072 | 2632539.56 | 2647775.76 |
6 | 15253 | 2562025.61 | 2577802.26 |
8 | 13448 | 2230345.42 | 2244467.88 |
2 | 13449 | 2188884.72 | 2202022.42 |
9 | 13109 | 2084992.09 | 2097560.13 |
1 | 10903 | 1811768.38 | 1822256.73 |
Clearly, Month 12 Which is december is the highest sales with nearly $4614000. we need to visualize it to make people easier to understand.
import matplotlib.pyplot as matlib
import plotly.express as px
months=range(1,13) #x axes
result=data.groupby('Month').sum()
matlib.bar(months, result['Sales'])
label, location = matlib.yticks()
matlib.yticks(label,(label/1000000).astype(int))
matlib.xlabel('Month in Number')
matlib.ylabel('Sales in Million USD')
matlib.show()
px.bar(Monthly_sales, y= 'Sales', color='Quantity Ordered')
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | |
---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 |
data['City'] = data['Purchase Address'].apply(lambda x: x.split(',')[1])+ " " +data['Purchase Address'].apply(lambda x: x.split(',')[2].split(' ')[1])
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | |
---|---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 | Dallas TX |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 | Boston MA |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA |
sales_by_city = data.groupby(['City']).agg({'Sales':'sum'}).reset_index()
sales_by_city
City | Sales | |
---|---|---|
0 | Atlanta GA | 2795498.58 |
1 | Austin TX | 1819581.75 |
2 | Boston MA | 3661642.01 |
3 | Dallas TX | 2767975.40 |
4 | Los Angeles CA | 5452570.80 |
5 | New York City NY | 4664317.43 |
6 | Portland ME | 449758.27 |
7 | Portland OR | 1870732.34 |
8 | San Francisco CA | 8262203.91 |
9 | Seattle WA | 2747755.48 |
sales_by_city.sort_values('Sales', ascending=False)
City | Sales | |
---|---|---|
8 | San Francisco CA | 8262203.91 |
4 | Los Angeles CA | 5452570.80 |
5 | New York City NY | 4664317.43 |
2 | Boston MA | 3661642.01 |
0 | Atlanta GA | 2795498.58 |
3 | Dallas TX | 2767975.40 |
9 | Seattle WA | 2747755.48 |
7 | Portland OR | 1870732.34 |
1 | Austin TX | 1819581.75 |
6 | Portland ME | 449758.27 |
px.bar(sales_by_city, x='City', y='Sales')
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | |
---|---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 | Dallas TX |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 | Boston MA |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA |
data['Order Date_DTO']=pd.to_datetime(data['Order Date'])
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Order Date_DTO | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 | Dallas TX | 2019-04-19 08:46:00 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 | Boston MA | 2019-04-07 22:30:00 |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA | 2019-04-12 14:38:00 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-12 14:38:00 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-30 09:27:00 |
data['Hour'] = data['Order Date_DTO'].dt.hour
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Order Date_DTO | Hour | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 | Dallas TX | 2019-04-19 08:46:00 | 8 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 | Boston MA | 2019-04-07 22:30:00 | 22 |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA | 2019-04-12 14:38:00 | 14 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-12 14:38:00 | 14 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-30 09:27:00 | 9 |
hours_count = data.groupby(['Hour']).count().reset_index()
hours_count.head()
Hour | Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Order Date_DTO | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 3910 | 3910 | 3910 | 3910 | 3910 | 3910 | 3910 | 3910 | 3910 | 3910 |
1 | 1 | 2350 | 2350 | 2350 | 2350 | 2350 | 2350 | 2350 | 2350 | 2350 | 2350 |
2 | 2 | 1243 | 1243 | 1243 | 1243 | 1243 | 1243 | 1243 | 1243 | 1243 | 1243 |
3 | 3 | 831 | 831 | 831 | 831 | 831 | 831 | 831 | 831 | 831 | 831 |
4 | 4 | 854 | 854 | 854 | 854 | 854 | 854 | 854 | 854 | 854 | 854 |
px.line(hours_count, x='Hour', y='Quantity Ordered')
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Order Date_DTO | Hour | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 | Dallas TX | 2019-04-19 08:46:00 | 8 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 | Boston MA | 2019-04-07 22:30:00 | 22 |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA | 2019-04-12 14:38:00 | 14 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-12 14:38:00 | 14 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-30 09:27:00 | 9 |
new_data = data[data['Order ID'].duplicated(keep=False)]
#join product with same order ID
new_data['Sold_together'] = new_data.groupby('Order ID')['Product'].transform(lambda x: ','.join(x))
new_data.head()
C:\Users\HP\AppData\Local\Temp\ipykernel_3908\4287307258.py:4: 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
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Order Date_DTO | Hour | Sold_together | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA | 2019-04-12 14:38:00 | 14 | Google Phone,Wired Headphones |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-12 14:38:00 | 14 | Google Phone,Wired Headphones |
18 | 176574 | Google Phone | 1 | 600.00 | 04/03/19 19:42 | 20 Hill St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA | 2019-04-03 19:42:00 | 19 | Google Phone,USB-C Charging Cable |
19 | 176574 | USB-C Charging Cable | 1 | 11.95 | 04/03/19 19:42 | 20 Hill St, Los Angeles, CA 90001 | 4 | 11.95 | Los Angeles CA | 2019-04-03 19:42:00 | 19 | Google Phone,USB-C Charging Cable |
30 | 176585 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 11:31 | 823 Highland St, Boston, MA 02215 | 4 | 99.99 | Boston MA | 2019-04-07 11:31:00 | 11 | Bose SoundSport Headphones,Bose SoundSport Hea... |
#dropping duplicate values
new_data = new_data[['Order ID', 'Sold_together']].drop_duplicates()
new_data.head()
Order ID | Sold_together | |
---|---|---|
3 | 176560 | Google Phone,Wired Headphones |
18 | 176574 | Google Phone,USB-C Charging Cable |
30 | 176585 | Bose SoundSport Headphones,Bose SoundSport Hea... |
32 | 176586 | AAA Batteries (4-pack),Google Phone |
119 | 176672 | Lightning Charging Cable,USB-C Charging Cable |
from itertools import combinations
from collections import Counter
count=Counter()
for row in new_data['Sold_together']:
row_list = row.split(',')
count.update(Counter(combinations(row_list,2)))
print(count)
Counter({('iPhone', 'Lightning Charging Cable'): 1005, ('Google Phone', 'USB-C Charging Cable'): 987, ('iPhone', 'Wired Headphones'): 447, ('Google Phone', 'Wired Headphones'): 414, ('Vareebadd Phone', 'USB-C Charging Cable'): 361, ('iPhone', 'Apple Airpods Headphones'): 360, ('Google Phone', 'Bose SoundSport Headphones'): 220, ('USB-C Charging Cable', 'Wired Headphones'): 160, ('Vareebadd Phone', 'Wired Headphones'): 143, ('Lightning Charging Cable', 'Wired Headphones'): 92, ('Lightning Charging Cable', 'Apple Airpods Headphones'): 81, ('Vareebadd Phone', 'Bose SoundSport Headphones'): 80, ('USB-C Charging Cable', 'Bose SoundSport Headphones'): 77, ('Apple Airpods Headphones', 'Wired Headphones'): 69, ('Lightning Charging Cable', 'USB-C Charging Cable'): 58, ('Lightning Charging Cable', 'AA Batteries (4-pack)'): 55, ('Lightning Charging Cable', 'Lightning Charging Cable'): 54, ('Bose SoundSport Headphones', 'Wired Headphones'): 53, ('AA Batteries (4-pack)', 'Lightning Charging Cable'): 51, ('AAA Batteries (4-pack)', 'USB-C Charging Cable'): 50, ('Apple Airpods Headphones', 'AAA Batteries (4-pack)'): 48, ('AA Batteries (4-pack)', 'AAA Batteries (4-pack)'): 48, ('USB-C Charging Cable', 'USB-C Charging Cable'): 48, ('AAA Batteries (4-pack)', 'AAA Batteries (4-pack)'): 48, ('USB-C Charging Cable', 'AAA Batteries (4-pack)'): 45, ('Wired Headphones', 'USB-C Charging Cable'): 45, ('AA Batteries (4-pack)', 'Wired Headphones'): 44, ('AAA Batteries (4-pack)', 'Lightning Charging Cable'): 44, ('AAA Batteries (4-pack)', 'Wired Headphones'): 43, ('Wired Headphones', 'AAA Batteries (4-pack)'): 43, ('USB-C Charging Cable', 'Lightning Charging Cable'): 42, ('AA Batteries (4-pack)', 'Apple Airpods Headphones'): 41, ('AAA Batteries (4-pack)', 'AA Batteries (4-pack)'): 39, ('Wired Headphones', 'AA Batteries (4-pack)'): 39, ('Lightning Charging Cable', 'Bose SoundSport Headphones'): 39, ('USB-C Charging Cable', 'AA Batteries (4-pack)'): 38, ('Bose SoundSport Headphones', 'AAA Batteries (4-pack)'): 37, ('AA Batteries (4-pack)', 'USB-C Charging Cable'): 37, ('Wired Headphones', 'Lightning Charging Cable'): 37, ('Lightning Charging Cable', 'AAA Batteries (4-pack)'): 36, ('Apple Airpods Headphones', 'Lightning Charging Cable'): 35, ('Wired Headphones', 'Wired Headphones'): 35, ('AA Batteries (4-pack)', 'AA Batteries (4-pack)'): 35, ('USB-C Charging Cable', 'Apple Airpods Headphones'): 34, ('Bose SoundSport Headphones', 'Lightning Charging Cable'): 33, ('AAA Batteries (4-pack)', 'Apple Airpods Headphones'): 33, ('Apple Airpods Headphones', 'Bose SoundSport Headphones'): 32, ('Wired Headphones', 'Apple Airpods Headphones'): 31, ('USB-C Charging Cable', '27in FHD Monitor'): 31, ('Apple Airpods Headphones', 'USB-C Charging Cable'): 29, ('Apple Airpods Headphones', 'AA Batteries (4-pack)'): 29, ('AA Batteries (4-pack)', 'Bose SoundSport Headphones'): 28, ('Bose SoundSport Headphones', 'Bose SoundSport Headphones'): 27, ('Bose SoundSport Headphones', 'AA Batteries (4-pack)'): 27, ('Bose SoundSport Headphones', 'USB-C Charging Cable'): 25, ('Apple Airpods Headphones', 'Apple Airpods Headphones'): 24, ('AAA Batteries (4-pack)', '27in FHD Monitor'): 22, ('27in FHD Monitor', 'AAA Batteries (4-pack)'): 21, ('Wired Headphones', 'Bose SoundSport Headphones'): 21, ('AAA Batteries (4-pack)', 'Bose SoundSport Headphones'): 20, ('34in Ultrawide Monitor', 'AA Batteries (4-pack)'): 19, ('Lightning Charging Cable', '27in 4K Gaming Monitor'): 18, ('AA Batteries (4-pack)', 'iPhone'): 18, ('27in FHD Monitor', 'Lightning Charging Cable'): 18, ('Lightning Charging Cable', '27in FHD Monitor'): 18, ('34in Ultrawide Monitor', 'Lightning Charging Cable'): 18, ('Wired Headphones', '27in 4K Gaming Monitor'): 18, ('Bose SoundSport Headphones', 'Apple Airpods Headphones'): 18, ('iPhone', 'AAA Batteries (4-pack)'): 17, ('Wired Headphones', '34in Ultrawide Monitor'): 17, ('ThinkPad Laptop', 'AAA Batteries (4-pack)'): 16, ('Lightning Charging Cable', 'Google Phone'): 16, ('27in 4K Gaming Monitor', 'Lightning Charging Cable'): 16, ('34in Ultrawide Monitor', 'USB-C Charging Cable'): 15, ('27in FHD Monitor', 'AA Batteries (4-pack)'): 15, ('Wired Headphones', 'iPhone'): 15, ('AAA Batteries (4-pack)', '27in 4K Gaming Monitor'): 15, ('iPhone', 'USB-C Charging Cable'): 15, ('20in Monitor', 'USB-C Charging Cable'): 15, ('Lightning Charging Cable', '20in Monitor'): 15, ('27in 4K Gaming Monitor', 'AAA Batteries (4-pack)'): 15, ('Lightning Charging Cable', '34in Ultrawide Monitor'): 15, ('Google Phone', 'AA Batteries (4-pack)'): 14, ('Apple Airpods Headphones', 'Google Phone'): 14, ('USB-C Charging Cable', 'iPhone'): 14, ('Bose SoundSport Headphones', '27in FHD Monitor'): 14, ('AA Batteries (4-pack)', '27in 4K Gaming Monitor'): 14, ('AAA Batteries (4-pack)', 'iPhone'): 14, ('iPhone', 'AA Batteries (4-pack)'): 14, ('AA Batteries (4-pack)', 'Flatscreen TV'): 13, ('AA Batteries (4-pack)', '34in Ultrawide Monitor'): 13, ('AAA Batteries (4-pack)', '34in Ultrawide Monitor'): 13, ('Apple Airpods Headphones', 'iPhone'): 13, ('Wired Headphones', 'Macbook Pro Laptop'): 13, ('Apple Airpods Headphones', '27in 4K Gaming Monitor'): 12, ('Apple Airpods Headphones', '27in FHD Monitor'): 12, ('27in FHD Monitor', 'Bose SoundSport Headphones'): 12, ('27in FHD Monitor', 'USB-C Charging Cable'): 12, ('Google Phone', 'Lightning Charging Cable'): 12, ('Apple Airpods Headphones', 'Macbook Pro Laptop'): 12, ('27in 4K Gaming Monitor', 'USB-C Charging Cable'): 12, ('Macbook Pro Laptop', 'USB-C Charging Cable'): 12, ('Wired Headphones', '27in FHD Monitor'): 12, ('20in Monitor', 'Wired Headphones'): 12, ('Lightning Charging Cable', 'Flatscreen TV'): 12, ('27in FHD Monitor', 'Apple Airpods Headphones'): 12, ('USB-C Charging Cable', 'Google Phone'): 12, ('27in 4K Gaming Monitor', 'AA Batteries (4-pack)'): 12, ('34in Ultrawide Monitor', 'AAA Batteries (4-pack)'): 12, ('AAA Batteries (4-pack)', 'Google Phone'): 11, ('AAA Batteries (4-pack)', 'Macbook Pro Laptop'): 11, ('USB-C Charging Cable', '27in 4K Gaming Monitor'): 11, ('USB-C Charging Cable', 'ThinkPad Laptop'): 11, ('34in Ultrawide Monitor', 'Wired Headphones'): 11, ('20in Monitor', 'Lightning Charging Cable'): 11, ('AA Batteries (4-pack)', '27in FHD Monitor'): 11, ('Bose SoundSport Headphones', '34in Ultrawide Monitor'): 11, ('ThinkPad Laptop', 'Lightning Charging Cable'): 11, ('Google Phone', 'AAA Batteries (4-pack)'): 11, ('USB-C Charging Cable', '34in Ultrawide Monitor'): 11, ('Macbook Pro Laptop', 'Lightning Charging Cable'): 11, ('AA Batteries (4-pack)', 'Google Phone'): 11, ('AAA Batteries (4-pack)', 'ThinkPad Laptop'): 11, ('Macbook Pro Laptop', 'Bose SoundSport Headphones'): 11, ('27in 4K Gaming Monitor', 'Wired Headphones'): 11, ('Flatscreen TV', 'AAA Batteries (4-pack)'): 11, ('Flatscreen TV', 'Lightning Charging Cable'): 10, ('Wired Headphones', 'ThinkPad Laptop'): 10, ('USB-C Charging Cable', '20in Monitor'): 10, ('27in 4K Gaming Monitor', 'Apple Airpods Headphones'): 10, ('USB-C Charging Cable', 'Flatscreen TV'): 10, ('27in FHD Monitor', 'Wired Headphones'): 10, ('AA Batteries (4-pack)', '20in Monitor'): 10, ('AAA Batteries (4-pack)', 'Flatscreen TV'): 10, ('Lightning Charging Cable', 'iPhone'): 10, ('Bose SoundSport Headphones', 'Flatscreen TV'): 10, ('Lightning Charging Cable', 'Macbook Pro Laptop'): 10, ('Bose SoundSport Headphones', '27in 4K Gaming Monitor'): 10, ('Apple Airpods Headphones', 'ThinkPad Laptop'): 9, ('Wired Headphones', 'Google Phone'): 9, ('27in 4K Gaming Monitor', 'Bose SoundSport Headphones'): 9, ('20in Monitor', 'Bose SoundSport Headphones'): 9, ('Macbook Pro Laptop', 'AA Batteries (4-pack)'): 9, ('ThinkPad Laptop', 'USB-C Charging Cable'): 9, ('ThinkPad Laptop', 'Bose SoundSport Headphones'): 9, ('Vareebadd Phone', 'AA Batteries (4-pack)'): 9, ('USB-C Charging Cable', 'Macbook Pro Laptop'): 9, ('27in FHD Monitor', '27in FHD Monitor'): 9, ('AA Batteries (4-pack)', 'ThinkPad Laptop'): 9, ('Lightning Charging Cable', 'ThinkPad Laptop'): 9, ('AA Batteries (4-pack)', 'Macbook Pro Laptop'): 8, ('Flatscreen TV', 'AA Batteries (4-pack)'): 8, ('Apple Airpods Headphones', 'Flatscreen TV'): 8, ('ThinkPad Laptop', 'AA Batteries (4-pack)'): 8, ('AAA Batteries (4-pack)', '20in Monitor'): 8, ('34in Ultrawide Monitor', 'Apple Airpods Headphones'): 8, ('Bose SoundSport Headphones', 'Google Phone'): 8, ('20in Monitor', 'Apple Airpods Headphones'): 7, ('Macbook Pro Laptop', 'Apple Airpods Headphones'): 7, ('Wired Headphones', 'Flatscreen TV'): 7, ('Wired Headphones', '20in Monitor'): 7, ('Macbook Pro Laptop', 'Wired Headphones'): 7, ('USB-C Charging Cable', 'Vareebadd Phone'): 7, ('Google Phone', '27in FHD Monitor'): 7, ('Macbook Pro Laptop', 'AAA Batteries (4-pack)'): 7, ('34in Ultrawide Monitor', 'iPhone'): 7, ('34in Ultrawide Monitor', '34in Ultrawide Monitor'): 7, ('Flatscreen TV', 'USB-C Charging Cable'): 7, ('Bose SoundSport Headphones', 'iPhone'): 7, ('ThinkPad Laptop', 'Apple Airpods Headphones'): 7, ('Google Phone', 'Apple Airpods Headphones'): 7, ('Macbook Pro Laptop', '27in 4K Gaming Monitor'): 7, ('iPhone', '27in 4K Gaming Monitor'): 6, ('Flatscreen TV', 'Flatscreen TV'): 6, ('Apple Airpods Headphones', '34in Ultrawide Monitor'): 6, ('iPhone', '34in Ultrawide Monitor'): 6, ('Vareebadd Phone', 'Apple Airpods Headphones'): 6, ('27in 4K Gaming Monitor', '34in Ultrawide Monitor'): 6, ('27in 4K Gaming Monitor', 'Macbook Pro Laptop'): 6, ('Bose SoundSport Headphones', '20in Monitor'): 6, ('iPhone', 'Flatscreen TV'): 6, ('Apple Airpods Headphones', '20in Monitor'): 6, ('Apple Airpods Headphones', 'Vareebadd Phone'): 6, ('Wired Headphones', 'Vareebadd Phone'): 6, ('34in Ultrawide Monitor', 'Bose SoundSport Headphones'): 6, ('Google Phone', 'iPhone'): 6, ('27in FHD Monitor', 'Macbook Pro Laptop'): 6, ('20in Monitor', 'AA Batteries (4-pack)'): 6, ('iPhone', 'Bose SoundSport Headphones'): 5, ('27in 4K Gaming Monitor', '27in 4K Gaming Monitor'): 5, ('Flatscreen TV', '34in Ultrawide Monitor'): 5, ('27in 4K Gaming Monitor', 'Google Phone'): 5, ('27in FHD Monitor', '34in Ultrawide Monitor'): 5, ('Flatscreen TV', 'Apple Airpods Headphones'): 5, ('34in Ultrawide Monitor', '27in FHD Monitor'): 5, ('Macbook Pro Laptop', '34in Ultrawide Monitor'): 4, ('iPhone', 'Vareebadd Phone'): 4, ('Bose SoundSport Headphones', 'ThinkPad Laptop'): 4, ('20in Monitor', 'Macbook Pro Laptop'): 4, ('Vareebadd Phone', '34in Ultrawide Monitor'): 4, ('Flatscreen TV', 'Wired Headphones'): 4, ('Flatscreen TV', '27in FHD Monitor'): 4, ('LG Dryer', 'AA Batteries (4-pack)'): 4, ('Flatscreen TV', 'Macbook Pro Laptop'): 4, ('27in FHD Monitor', '27in 4K Gaming Monitor'): 4, ('ThinkPad Laptop', 'Flatscreen TV'): 4, ('Flatscreen TV', 'iPhone'): 4, ('27in 4K Gaming Monitor', 'ThinkPad Laptop'): 4, ('Vareebadd Phone', 'Google Phone'): 4, ('Macbook Pro Laptop', 'Google Phone'): 4, ('27in 4K Gaming Monitor', '27in FHD Monitor'): 4, ('Lightning Charging Cable', 'LG Washing Machine'): 4, ('27in FHD Monitor', 'ThinkPad Laptop'): 4, ('ThinkPad Laptop', 'Wired Headphones'): 4, ('iPhone', 'ThinkPad Laptop'): 4, ('Bose SoundSport Headphones', 'Macbook Pro Laptop'): 4, ('AAA Batteries (4-pack)', 'Vareebadd Phone'): 4, ('LG Washing Machine', 'AAA Batteries (4-pack)'): 4, ('Macbook Pro Laptop', 'ThinkPad Laptop'): 3, ('ThinkPad Laptop', 'Google Phone'): 3, ('34in Ultrawide Monitor', 'Macbook Pro Laptop'): 3, ('Lightning Charging Cable', 'Vareebadd Phone'): 3, ('Google Phone', 'ThinkPad Laptop'): 3, ('20in Monitor', '20in Monitor'): 3, ('ThinkPad Laptop', 'iPhone'): 3, ('Vareebadd Phone', 'Flatscreen TV'): 3, ('34in Ultrawide Monitor', 'Flatscreen TV'): 3, ('Macbook Pro Laptop', 'Macbook Pro Laptop'): 3, ('34in Ultrawide Monitor', 'ThinkPad Laptop'): 3, ('Macbook Pro Laptop', 'iPhone'): 3, ('Vareebadd Phone', 'iPhone'): 3, ('Wired Headphones', 'LG Washing Machine'): 3, ('Google Phone', '34in Ultrawide Monitor'): 3, ('Macbook Pro Laptop', '27in FHD Monitor'): 3, ('Flatscreen TV', 'Bose SoundSport Headphones'): 3, ('AA Batteries (4-pack)', 'Vareebadd Phone'): 3, ('27in FHD Monitor', '20in Monitor'): 3, ('iPhone', 'Google Phone'): 3, ('27in 4K Gaming Monitor', 'iPhone'): 3, ('Google Phone', 'Google Phone'): 3, ('Flatscreen TV', 'Google Phone'): 3, ('Google Phone', 'Macbook Pro Laptop'): 3, ('27in 4K Gaming Monitor', 'Flatscreen TV'): 3, ('Apple Airpods Headphones', 'LG Dryer'): 3, ('20in Monitor', 'AAA Batteries (4-pack)'): 3, ('iPhone', 'Macbook Pro Laptop'): 3, ('34in Ultrawide Monitor', 'Google Phone'): 2, ('Macbook Pro Laptop', '20in Monitor'): 2, ('Lightning Charging Cable', 'LG Dryer'): 2, ('Flatscreen TV', '27in 4K Gaming Monitor'): 2, ('ThinkPad Laptop', 'Macbook Pro Laptop'): 2, ('Macbook Pro Laptop', 'LG Washing Machine'): 2, ('20in Monitor', '27in FHD Monitor'): 2, ('ThinkPad Laptop', 'ThinkPad Laptop'): 2, ('Bose SoundSport Headphones', 'Vareebadd Phone'): 2, ('Vareebadd Phone', 'ThinkPad Laptop'): 2, ('20in Monitor', 'ThinkPad Laptop'): 2, ('iPhone', 'iPhone'): 2, ('27in FHD Monitor', 'LG Dryer'): 2, ('Vareebadd Phone', '27in 4K Gaming Monitor'): 2, ('27in 4K Gaming Monitor', '20in Monitor'): 2, ('LG Washing Machine', 'Lightning Charging Cable'): 2, ('LG Washing Machine', 'Bose SoundSport Headphones'): 2, ('AA Batteries (4-pack)', 'LG Dryer'): 2, ('Vareebadd Phone', 'AAA Batteries (4-pack)'): 2, ('iPhone', '20in Monitor'): 2, ('20in Monitor', 'Google Phone'): 2, ('Flatscreen TV', 'ThinkPad Laptop'): 2, ('ThinkPad Laptop', '27in FHD Monitor'): 2, ('27in FHD Monitor', 'Flatscreen TV'): 2, ('Google Phone', '20in Monitor'): 2, ('27in 4K Gaming Monitor', 'Vareebadd Phone'): 1, ('27in FHD Monitor', 'iPhone'): 1, ('Vareebadd Phone', 'Lightning Charging Cable'): 1, ('Google Phone', 'Vareebadd Phone'): 1, ('20in Monitor', 'iPhone'): 1, ('LG Dryer', 'Vareebadd Phone'): 1, ('Macbook Pro Laptop', 'Flatscreen TV'): 1, ('ThinkPad Laptop', 'Vareebadd Phone'): 1, ('Google Phone', 'Flatscreen TV'): 1, ('LG Washing Machine', 'Google Phone'): 1, ('LG Washing Machine', 'Wired Headphones'): 1, ('LG Dryer', 'Flatscreen TV'): 1, ('27in FHD Monitor', 'LG Washing Machine'): 1, ('LG Dryer', '27in FHD Monitor'): 1, ('20in Monitor', '34in Ultrawide Monitor'): 1, ('34in Ultrawide Monitor', '20in Monitor'): 1, ('34in Ultrawide Monitor', 'LG Washing Machine'): 1, ('Google Phone', '27in 4K Gaming Monitor'): 1, ('LG Washing Machine', 'iPhone'): 1, ('LG Dryer', 'Wired Headphones'): 1, ('27in FHD Monitor', 'Vareebadd Phone'): 1, ('LG Washing Machine', '27in 4K Gaming Monitor'): 1, ('LG Washing Machine', 'Apple Airpods Headphones'): 1, ('27in 4K Gaming Monitor', 'LG Dryer'): 1, ('20in Monitor', 'LG Washing Machine'): 1, ('LG Dryer', 'Google Phone'): 1, ('Vareebadd Phone', '27in FHD Monitor'): 1, ('ThinkPad Laptop', '27in 4K Gaming Monitor'): 1, ('20in Monitor', 'Flatscreen TV'): 1, ('USB-C Charging Cable', 'LG Dryer'): 1, ('LG Washing Machine', '20in Monitor'): 1, ('Flatscreen TV', '20in Monitor'): 1, ('27in FHD Monitor', 'Google Phone'): 1, ('iPhone', '27in FHD Monitor'): 1, ('LG Dryer', 'AAA Batteries (4-pack)'): 1, ('ThinkPad Laptop', '34in Ultrawide Monitor'): 1, ('iPhone', 'LG Washing Machine'): 1, ('AAA Batteries (4-pack)', 'LG Dryer'): 1, ('LG Dryer', '27in 4K Gaming Monitor'): 1, ('LG Dryer', 'Lightning Charging Cable'): 1, ('ThinkPad Laptop', 'LG Dryer'): 1, ('LG Washing Machine', 'AA Batteries (4-pack)'): 1})
count.most_common(10)
[(('iPhone', 'Lightning Charging Cable'), 1005), (('Google Phone', 'USB-C Charging Cable'), 987), (('iPhone', 'Wired Headphones'), 447), (('Google Phone', 'Wired Headphones'), 414), (('Vareebadd Phone', 'USB-C Charging Cable'), 361), (('iPhone', 'Apple Airpods Headphones'), 360), (('Google Phone', 'Bose SoundSport Headphones'), 220), (('USB-C Charging Cable', 'Wired Headphones'), 160), (('Vareebadd Phone', 'Wired Headphones'), 143), (('Lightning Charging Cable', 'Wired Headphones'), 92)]
px.bar(new_data, y='Sold_together',width=1000,height=800)
px.treemap(new_data , path = ['Sold_together'] , values = 'Order ID')
px.sunburst(new_data, path=['Sold_together'], values = 'Order ID')
data.head()
Order ID | Product | Quantity Ordered | Price Each | Order Date | Purchase Address | Month | Sales | City | Order Date_DTO | Hour | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 176558 | USB-C Charging Cable | 2 | 11.95 | 04/19/19 08:46 | 917 1st St, Dallas, TX 75001 | 4 | 23.90 | Dallas TX | 2019-04-19 08:46:00 | 8 |
2 | 176559 | Bose SoundSport Headphones | 1 | 99.99 | 04/07/19 22:30 | 682 Chestnut St, Boston, MA 02215 | 4 | 99.99 | Boston MA | 2019-04-07 22:30:00 | 22 |
3 | 176560 | Google Phone | 1 | 600.00 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 600.00 | Los Angeles CA | 2019-04-12 14:38:00 | 14 |
4 | 176560 | Wired Headphones | 1 | 11.99 | 04/12/19 14:38 | 669 Spruce St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-12 14:38:00 | 14 |
5 | 176561 | Wired Headphones | 1 | 11.99 | 04/30/19 09:27 | 333 8th St, Los Angeles, CA 90001 | 4 | 11.99 | Los Angeles CA | 2019-04-30 09:27:00 | 9 |
product_group = data.groupby('Product')
product_group.sum()
Quantity Ordered | Price Each | Month | Sales | Hour | |
---|---|---|---|---|---|
Product | |||||
20in Monitor | 4129 | 451068.99 | 29336 | 454148.71 | 58764 |
27in 4K Gaming Monitor | 6244 | 2429637.70 | 44440 | 2435097.56 | 90916 |
27in FHD Monitor | 7550 | 1125974.93 | 52558 | 1132424.50 | 107540 |
34in Ultrawide Monitor | 6199 | 2348718.19 | 43304 | 2355558.01 | 89076 |
AA Batteries (4-pack) | 27635 | 79015.68 | 145558 | 106118.40 | 298342 |
AAA Batteries (4-pack) | 31017 | 61716.59 | 146370 | 92740.83 | 297332 |
Apple Airpods Headphones | 15661 | 2332350.00 | 109477 | 2349150.00 | 223304 |
Bose SoundSport Headphones | 13457 | 1332366.75 | 94113 | 1345565.43 | 192445 |
Flatscreen TV | 4819 | 1440000.00 | 34224 | 1445700.00 | 68815 |
Google Phone | 5532 | 3315000.00 | 38305 | 3319200.00 | 79479 |
LG Dryer | 646 | 387600.00 | 4383 | 387600.00 | 9326 |
LG Washing Machine | 666 | 399600.00 | 4523 | 399600.00 | 9785 |
Lightning Charging Cable | 23217 | 323787.10 | 153092 | 347094.15 | 312529 |
Macbook Pro Laptop | 4728 | 8030800.00 | 33548 | 8037600.00 | 68261 |
ThinkPad Laptop | 4130 | 4127958.72 | 28950 | 4129958.70 | 59746 |
USB-C Charging Cable | 23975 | 261740.85 | 154819 | 286501.25 | 314645 |
Vareebadd Phone | 2068 | 826000.00 | 14309 | 827200.00 | 29472 |
Wired Headphones | 20557 | 226395.18 | 133397 | 246478.43 | 271720 |
iPhone | 6849 | 4789400.00 | 47941 | 4794300.00 | 98657 |
quantity_ordered = product_group.sum()['Quantity Ordered'].reset_index()
quantity_ordered
Product | Quantity Ordered | |
---|---|---|
0 | 20in Monitor | 4129 |
1 | 27in 4K Gaming Monitor | 6244 |
2 | 27in FHD Monitor | 7550 |
3 | 34in Ultrawide Monitor | 6199 |
4 | AA Batteries (4-pack) | 27635 |
5 | AAA Batteries (4-pack) | 31017 |
6 | Apple Airpods Headphones | 15661 |
7 | Bose SoundSport Headphones | 13457 |
8 | Flatscreen TV | 4819 |
9 | Google Phone | 5532 |
10 | LG Dryer | 646 |
11 | LG Washing Machine | 666 |
12 | Lightning Charging Cable | 23217 |
13 | Macbook Pro Laptop | 4728 |
14 | ThinkPad Laptop | 4130 |
15 | USB-C Charging Cable | 23975 |
16 | Vareebadd Phone | 2068 |
17 | Wired Headphones | 20557 |
18 | iPhone | 6849 |
px.bar(quantity_ordered, y='Quantity Ordered', x='Product')
Now we can see what product sold the most, it’s AAA Batteries(4 pack). We can also see that AA Batteries (4 pack), Lightning Charging Cable, USB-C Charging Cable, and Wired Headphones are sold more than other products. But, Why are they sold the most?
The first impression is that they are cheaper than other products. As a data analyst, let’s prove this hypothesis.
prices = data.groupby('Product').min()['Price Each']
prices
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
px.line(prices,y='Price Each')
What was the best month for sales? How much was earned that month?
The best month for sales is December. The company earned approximately $ 4,61,400.
What city sold the most product?
San Fransisco is the city with the highest sales.
What time should we display advertisements to maximize likelihood of customer’s buying products?
We can suggest to advertise the products right before 12 PM and/or 7 PM. It could be 11.30 AM and/or 6.30 PM.
What Products are most often sold together?
The most often products sold together are iPhone and Lightning Charging Cable with 1005 transactions.
What product sold the most? Why?
AAA Batteries(4 pack) is the most sold product. Because it’s cheaper than other products and has high demand. </a>