Descriptive analytics and EDA
hub-tealbox-assignment
August 8, 2024
[1]: import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
import datetime
from datetime import datetime
import calendar
[2]: df = pd.read_excel(r"E:\interviwe_assignment\Tealbox Digital.xlsx")
df.head()
[2]:
0
1
2
3
4
Cloud_Kitchen_Business
Cloud_Kitchen_Business
Cloud_Kitchen_Business
Cloud_Kitchen_Business
Cloud_Kitchen_Business
(Ahmedabad
(Ahmedabad
(Ahmedabad
(Ahmedabad
(Ahmedabad
0
1
2
3
4
invoice_no-
date payment_type
11:10:00
Online
11:14:00
Online
11:42:00
Online
11:43:00
Online
11:47:00
Online
0
1
2
3
4
total_tax-
discount-
0
round_off
-0.08
total
129
-
…
…
…
…
…
…
-
outlet
Bodakdev)
Bodakdev)
Bodakdev)
Bodakdev)
Bodakdev)
container_charge-
brand
Bowl_Meals
Bowl_Meals
Bowl_Meals
North_Indian_Meals
Bowl_Meals
status channel
Success Zomato
Success Swiggy
Success Swiggy
Success Swiggy
Success Zomato
service_charge
0
0
0
0
0
\
my_amount-
waived_off
0
0
0
0
0
item_name
Butter Chicken Rice Meal
1
\
\
\
1
2
3
4
0
1
2
3
4
-0.16
-0.48
0.14
-0.40
-
Veg Dum Biryani Meal
Hot Garlic Schezwan Chicken & Veg Fried Rice Meal
Veg. Lunch Pack Thali
Chicken Chilli & Egg Fried Rice Meal
category_name item_price
Indian Meals [M101]
189
Indian Meals [M101]
159
Chinese Meals [M101]
169
Lunch Packs Thali [MB]
169
Egg Fried Rice Meals [M101]
179
item_quantity
1
1
1
3
1
item_total-
[5 rows x 21 columns]
[3]: df.drop(['delivery_charge','service_charge','waived_off','round_off'], axis=1,␣
↪inplace = True)
[4]: df.info()
RangeIndex: 32938 entries, 0 to 32937
Data columns (total 17 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
outlet
32938 non-null object
1
brand
32938 non-null object
2
invoice_no
32938 non-null int64
3
date
32938 non-null object
4
payment_type
32938 non-null object
5
status
32938 non-null object
6
channel
32938 non-null object
7
my_amount
32938 non-null int64
8
total_tax
32938 non-null float64
9
discount
32938 non-null float64
10 container_charge 32938 non-null int64
11 total
32938 non-null int64
12 item_name
32938 non-null object
13 category_name
32938 non-null object
14 item_price
32938 non-null int64
15 item_quantity
32938 non-null int64
16 item_total
32938 non-null int64
dtypes: float64(2), int64(7), object(8)
memory usage: 4.3+ MB
[5]: df.dropna(inplace = True)
df['date'] = pd.to_datetime(df['date'], dayfirst=True)
df['req_hour'] = df['date'].dt.hour
2
df.set_index('date', inplace= True)
df['day_of_week'] = df.index.strftime('%A')
df.head()
[5]:
outlet
date-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
Cloud_Kitchen_Business
Cloud_Kitchen_Business
Cloud_Kitchen_Business
Cloud_Kitchen_Business
Cloud_Kitchen_Business
brand
date-
date-
date-
date-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
(Ahmedabad
(Ahmedabad
(Ahmedabad
(Ahmedabad
(Ahmedabad
-
Bodakdev)
Bodakdev)
Bodakdev)
Bodakdev)
Bodakdev)
invoice_no payment_type
Bowl_Meals
Bowl_Meals
Bowl_Meals
North_Indian_Meals
Bowl_Meals
-
\
Online
Online
Online
Online
Online
status
\
Success
Success
Success
Success
Success
channel
my_amount
total_tax
discount
container_charge
Zomato
Swiggy
Swiggy
Swiggy
Zomato
-
-
-
-
total
item_name
-
Butter Chicken Rice Meal
Veg Dum Biryani Meal
Hot Garlic Schezwan Chicken & Veg Fried Rice Meal
Veg. Lunch Pack Thali
Chicken Chilli & Egg Fried Rice Meal
category_name
item_price
item_quantity
Indian Meals [M101]
Indian Meals [M101]
Chinese Meals [M101]
Lunch Packs Thali [MB]
Egg Fried Rice Meals [M101]
-
1
1
1
3
1
item_total
req_hour day_of_week
date
3
\
\
\
-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
-
-
Sunday
Sunday
Sunday
Sunday
Sunday
Data exploration and Manipulations
[6]: out = df['outlet'].str.split(" ", n=1, expand=True)
df['city_outlet'] = out[1]
df['city_outlet'] = df['city_outlet'].str.strip("()")
df.drop('outlet', axis=1, inplace=True)
df.head()
[6]:
brand
date-
date-
date-
date-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
invoice_no payment_type
Bowl_Meals
Bowl_Meals
Bowl_Meals
North_Indian_Meals
Bowl_Meals
-
Online
Online
Online
Online
Online
status
\
Success
Success
Success
Success
Success
channel
my_amount
total_tax
discount
container_charge
Zomato
Swiggy
Swiggy
Swiggy
Zomato
-
-
-
-
total
item_name
-
Butter Chicken Rice Meal
Veg Dum Biryani Meal
Hot Garlic Schezwan Chicken & Veg Fried Rice Meal
Veg. Lunch Pack Thali
Chicken Chilli & Egg Fried Rice Meal
category_name
item_price
item_quantity
Indian Meals [M101]
Indian Meals [M101]
Chinese Meals [M101]
Lunch Packs Thali [MB]
Egg Fried Rice Meals [M101]
-
1
1
1
3
1
item_total
req_hour day_of_week
4
city_outlet
\
\
\
date-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
-
-
Sunday
Sunday
Sunday
Sunday
Sunday
Ahmedabad
Ahmedabad
Ahmedabad
Ahmedabad
Ahmedabad
-
Bodakdev
Bodakdev
Bodakdev
Bodakdev
Bodakdev
[7]: df.payment_type.value_counts()
[7]: Online
31579
Cash
847
Other [PayTM]
148
CARD
123
Other [Paytm]
60
Other [Google Pay]
50
Other [paytm]
42
Other [Googlepay]
31
Other [GPAY]
17
Other [RAZORPAY]
12
Other [gpay]
10
Other [Online]
8
Other [Gpay]
5
Other [Google Pay](ROZAY PAY)
3
Other [Phone PE]
2
Other [phone pe]
1
Name: payment_type, dtype: int64
[8]: df['payment_type'] =df['payment_type'].replace(['Other [PayTM]','Other␣
↪[Paytm]','Other [paytm]'
,'Other [Google Pay]','Other [Googlepay]','Other [Google Pay](ROZAY PAY)'␣
↪,'Other [GPAY]','Other [gpay]','Other [GPAY]',
'Other [RAZORPAY]' , 'Other [gpay]', 'Other [Online]', 'Other [Gpay]', 'Other␣
↪[Phone PE]','Other [phone pe]'],
'UPI')
[9]: df_categorical = df.select_dtypes(include= ['object'])
[10]: df.info()
DatetimeIndex: 32938 entries,-:10:00 to-:49:00
Data columns (total 18 columns):
#
Column
Non-Null Count Dtype
-------------- ------- -----0
brand
32938 non-null object
1
invoice_no
32938 non-null int64
2
payment_type
32938 non-null object
5
3
status
32938 non-null object
4
channel
32938 non-null object
5
my_amount
32938 non-null int- non-null float64
6
total_tax
7
discount
32938 non-null float64
8
container_charge 32938 non-null int64
9
total
32938 non-null int64
10 item_name
32938 non-null object
11 category_name
32938 non-null object
12 item_price
32938 non-null int64
13 item_quantity
32938 non-null int64
14 item_total
32938 non-null int64
15 req_hour
32938 non-null int64
16 day_of_week
32938 non-null object
17 city_outlet
32938 non-null object
dtypes: float64(2), int64(8), object(8)
memory usage: 4.8+ MB
[11]: df.channel.value_counts()
[11]: Swiggy
17089
Zomato
14694
App/Web
1155
Name: channel, dtype: int64
[12]: df_numerical = df.select_dtypes(include= ['float','int64'])
#df_numerical.drop('invoice_no', axis=1, inplace = True)
[13]: df_numerical.head()
[13]:
date-
date-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
invoice_no
my_amount
total_tax
discount
-
-
-
-
\
container_charge
total
item_price
item_quantity
-
-
-
1
1
1
3
1
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
item_total
req_hour
6
\
date-
11:10:00
11:14:00
11:42:00
11:43:00
11:47:00
-
-
[130]: plt.figure(figsize=(15,10))
for measure in df_numerical:
plt.figure(figsize=(10,8))
sns.distplot(df.loc[df["channel"] == 'Swiggy', measure].dropna())
sns.distplot(df.loc[df["channel"] == 'Zomato', measure].dropna())
sns.distplot(df.loc[df["channel"] == 'App/Web', measure].dropna())
plt.legend(["Swiggy", "Zomato", "App/Web"])
plt.show()
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
7
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
8
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
9
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
10
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
11
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
12
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
13
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
14
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
15
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
16
[15]: df['Timeslot']=pd.cut(df['req_hour'],bins=[0,5,10,15,19,22,24],labels=["Early␣
↪Morning","Morning","Afternoon","Evening","Night","Late Night"])
[16]: df.info()
DatetimeIndex: 32938 entries,-:10:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----32938 non-null object
0
brand
1
invoice_no
32938 non-null int64
2
payment_type
32938 non-null object
3
status
32938 non-null object
4
channel
32938 non-null object
5
my_amount
32938 non-null int64
6
total_tax
32938 non-null float64
7
discount
32938 non-null float64
8
container_charge 32938 non-null int64
9
total
32938 non-null int64
17
10 item_name
32938 non-null object
11 category_name
32938 non-null object
12 item_price
32938 non-null int64
13 item_quantity
32938 non-null int64
14 item_total
32938 non-null int64
15 req_hour
32938 non-null int64
16 day_of_week
32938 non-null object
17 city_outlet
32938 non-null object
18 Timeslot
30366 non-null category
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 4.8+ MB
[17]: plt.figure(figsize=(5,8))
fig1=sns.countplot(hue='status',x='channel',data = df)
fig1.set_title("Status of Payment according to channel")
ncount=len(df)
for p in fig1.patches:
x=p.get_bbox().get_points()[:,0]
y=p.get_bbox().get_points()[1,1]
fig1.annotate((y),(x.mean(),y),ha='center',va='bottom')
plt.show()
18
[18]: plt.figure(figsize=(14, 6))
fig1=sns.countplot(hue ='payment_type',x='channel',data = df)
fig1.set_title("Status of Payment mode according to channel")
ncount=len(df)
for p in fig1.patches:
x=p.get_bbox().get_points()[:,0]
y=p.get_bbox().get_points()[1,1]
19
fig1.annotate((y),(x.mean(),y),ha='center',va='bottom')
plt.show()
[19]: percent = round(df.channel.value_counts()/len(df.index)*100,1)
sub=['Swiggy','Zomato','Others']
plt.axis("equal")
plt.pie(percent , labels=sub,radius=1.6,autopct='%1.2f%%',explode=[0.01,0.01,0.
↪01],startangle=90,shadow=True,counterclock=False,pctdistance=0.6)
plt.show()
20
[20]: df.channel.value_counts()
[20]: Swiggy
17089
Zomato
14694
App/Web
1155
Name: channel, dtype: int64
[21]: plt.figure(figsize=(10,6))
fig = sns.countplot(hue="channel",x = 'brand', data=df)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation = 90, fontsize = 14)
plt.title('No of Orders of diff brands of food for diff channels', fontsize =␣
↪12)
plt.xlabel('Channel of Opn', fontsize = 12)
plt.show()
21
[22]: plt.figure(figsize=(15,8))
fig = sns.countplot(hue="channel",x = 'city_outlet', data=df)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()),0)), fontsize=15, color='black',
rotation=0)
plt.xticks(rotation = 90, fontsize = 14)
plt.title('No of Orders of diff outlets for diff channels', fontsize = 12)
plt.xlabel('Channel of Opn', fontsize = 12)
plt.show()
22
[23]: plt.figure(figsize=(15,8))
fig = sns.countplot(hue="channel",x = 'day_of_week', data=df)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()),0)), fontsize=15, color='black',
rotation=0)
plt.title('No of Orders as per diff Channel for days of week', fontsize = 12)
plt.xlabel('Channel of Opn', fontsize = 12)
plt.show()
23
[24]: plt.figure(figsize=(16,8))
fig = sns.countplot(x="day_of_week",hue = 'Timeslot', data=df)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()),0)), fontsize=12, color='black',
rotation=0)
plt.xticks(rotation = 0, fontsize = 15)
plt.title('No of Orders per day per as per diff timeslots', fontsize = 15)
plt.xlabel('Channel of Opn', fontsize = 12)
plt.show()
24
[25]: plt.figure(figsize=(15,8))
fig = sns.countplot(hue="channel",x = 'Timeslot', data=df)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()),0)), fontsize=12, color='black',
rotation=0)
plt.xticks(rotation = 0, fontsize = 15)
plt.title('No of Orders as per diff Channel for diff Timeslots', fontsize = 15)
plt.xlabel('Channel of Opn', fontsize = 12)
plt.show()
25
[26]: # factor plot of hour and day w.r.t. status
plt.figure(figsize=(18,6))
fig = sns.catplot(x = "req_hour", hue = "channel", row = "day_of_week", data =␣
↪df, kind = "count")
plt.xticks(rotation=90, fontsize=12)
plt.show()
26
27
[27]: df.info()
DatetimeIndex: 32938 entries,-:10:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
brand
32938 non-null object
1
invoice_no
32938 non-null int64
2
payment_type
32938 non-null object
3
status
32938 non-null object
4
channel
32938 non-null object
5
my_amount
32938 non-null int64
6
total_tax
32938 non-null float64
7
discount
32938 non-null float64
8
container_charge 32938 non-null int64
9
total
32938 non-null int64
10 item_name
32938 non-null object
11 category_name
32938 non-null object
12 item_price
32938 non-null int64
13 item_quantity
32938 non-null int64
14 item_total
32938 non-null int64
15 req_hour
32938 non-null int64
16 day_of_week
32938 non-null object
17 city_outlet
32938 non-null object
18 Timeslot
30366 non-null category
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 4.8+ MB
[28]: plt.figure(figsize=(16,8))
fig = sns.barplot(y = 'discount', hue ='brand',x ='channel', data = df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.4, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation=90, fontsize=12)
plt.xlabel('city_outlet')
plt.ylabel('avg price of orders')
plt.title("Avg discount offred by each channel according to diff brands of food␣
↪",fontsize= 15)
28
plt.xticks(fontsize=12)
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.show()
[29]: plt.figure(figsize=(16,8))
fig = sns.barplot(y = 'discount', hue ='Timeslot',x ='channel', data = df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.4, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation=90, fontsize=12)
plt.xlabel('city_outlet')
plt.ylabel('avg price of orders')
plt.title("Avg discount offred by each channel according to diff Timeslots␣
↪",fontsize= 15)
plt.xticks(fontsize=12)
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.show()
29
[30]: plt.figure(figsize=(16,8))
fig = sns.barplot(y = 'total', hue ='brand',x ='Timeslot', data= df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.4, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation=90, fontsize=12)
plt.xlabel('city_outlet')
plt.ylabel('avg price of orders')
plt.title("Avg Orders Price for each brand according to TimeSlot",fontsize= 15)
plt.xticks(fontsize=12)
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.show()
posx and posy should be finite values
posx and posy should be finite values
30
[31]: plt.figure(figsize=(16,8))
fig = sns.barplot(y = 'total', hue ='brand',x ='city_outlet', data= df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.4, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation=90, fontsize=12)
plt.xlabel('city_outlet')
plt.ylabel('avg price of orders')
plt.title("Avg Orders Price from each Outlet vs for each brand",fontsize= 15)
plt.xticks(fontsize=12)
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.show()
posx
posx
posx
posx
posx
posx
and
and
and
and
and
and
posy
posy
posy
posy
posy
posy
should
should
should
should
should
should
be
be
be
be
be
be
finite
finite
finite
finite
finite
finite
values
values
values
values
values
values
31
posx and posy should be finite values
posx and posy should be finite values
[32]: plt.figure(figsize=(12,6))
fig = sns.barplot(y = 'total', hue ='channel',x ='city_outlet', data= df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.35, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=45)
plt.xticks(rotation=90, fontsize=12)
plt.xlabel('city_outlet')
plt.ylabel('avg price of orders')
plt.title("Avg Orders Price from each Outlet vs Channel of␣
↪Operations",fontsize= 15)
plt.xticks(fontsize=12)
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.show()
32
[33]: plt.figure(figsize=(12,6))
fig = sns.barplot(y = 'total', hue ='channel',x ='brand', data= df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.35, \
str(round((i.get_height()),0)), fontsize=14, color='black',
rotation=45)
plt.xticks(rotation=90, fontsize=12)
plt.xlabel('city_outlet')
plt.ylabel('avg price of orders')
plt.title("Avg Orders Price for each brand vs Channel of Operations",fontsize=␣
↪15)
plt.xticks(fontsize=12)
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.show()
33
[34]: plt.figure(figsize=(12,6))
fig = sns.barplot(y = 'total', hue ='channel',x ='day_of_week', data= df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()),0)), fontsize=12, color='black',
rotation=0)
plt.xlabel('channel')
plt.ylabel('avg price of orders')
plt.title("Avg Orders Price Each day of week vs Channel of␣
↪Operations",fontsize= 15)
plt.xticks(fontsize=15)
plt.legend(loc=2,shadow=True,fontsize='large')
plt.show()
34
[35]: plt.figure(figsize=(12,6))
fig = sns.barplot(y = 'item_quantity', hue ='channel',x ='Timeslot', data= df,␣
↪estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.01
, \
str(round((i.get_height()),0)), fontsize=15, color='black',
rotation=0)
plt.xlabel('channel')
plt.ylabel('quantity of orders')
plt.title("Avg Orders Size Each Hour vs Channel of Operations",fontsize= 15)
plt.xticks(fontsize=15)
plt.legend(loc=2,shadow=True,fontsize='large')
plt.show()
35
[36]: plt.figure(figsize=(5,5))
fig = sns.barplot(y = 'total', x ='channel',data= df, estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()), 2)), fontsize=15, color='black',
rotation=0)
plt.xlabel('channel')
plt.ylabel('avg price of orders')
plt.title("Avg Price of Orders vs Channel",fontsize= 15)
plt.xticks(fontsize=15)
plt.legend(loc=2,shadow=True,fontsize='large')
plt.show()
No handles with labels found to put in legend.
36
[37]: plt.figure(figsize=(18,8))
fig = sns.barplot(x = 'req_hour', y ='invoice_no',data= df, estimator=len)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.3, \
str(round((i.get_height()), 2)), fontsize=15, color='black',
rotation=0)
plt.xlabel('hour of day')
plt.ylabel('no of orders')
plt.title("No of Orders",fontsize= 25)
plt.xticks(fontsize=15)
plt.legend(loc=2,shadow=True,fontsize='x-large')
plt.show()
No handles with labels found to put in legend.
37
[38]: df_swiggy = df[df['channel']=='Swiggy']
df_zomato = df[df['channel']=='Zomato']
df_others = df[df['channel']=='App/Web']
[39]: df.info()
DatetimeIndex: 32938 entries,-:10:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
brand
32938 non-null object
1
invoice_no
32938 non-null int64
2
payment_type
32938 non-null object
3
status
32938 non-null object
4
channel
32938 non-null object
5
my_amount
32938 non-null int64
6
total_tax
32938 non-null float64
7
discount
32938 non-null float64
8
container_charge 32938 non-null int64
9
total
32938 non-null int64
10 item_name
32938 non-null object
11 category_name
32938 non-null object
12 item_price
32938 non-null int64
13 item_quantity
32938 non-null int64
14 item_total
32938 non-null int64
15 req_hour
32938 non-null int- non-null object
16 day_of_week
17 city_outlet
32938 non-null object
38
18 Timeslot
30366 non-null category
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 4.8+ MB
[40]: Time_pivot_df = df.
↪pivot_table(values=['total'],index=['day_of_week','Timeslot'],columns=['channel'],
aggfunc=np.mean)
Time_pivot_df
[40]:
channel
day_of_week Timeslot
Friday
Early Morning
Morning
Afternoon
Evening
Night
Late Night
Early Morning
Monday
Morning
Afternoon
Evening
Night
Late Night
Saturday
Early Morning
Morning
Afternoon
Evening
Night
Late Night
Sunday
Early Morning
Morning
Afternoon
Evening
Night
Late Night
Thursday
Early Morning
Morning
Afternoon
Evening
Night
Late Night
Tuesday
Early Morning
Morning
Afternoon
Evening
Night
total
App/Web
Swiggy
Zomato
NaN
NaN-
NaN-
NaN-
NaN-
-
-
39
Wednesday
Late Night
Early Morning
Morning
Afternoon
Evening
Night
Late Night
-
NaN-
-
-
[41]: outlet_pivot_df = df.
↪pivot_table(values=['total'],index=['city_outlet','brand'],columns=['channel'],
aggfunc=np.mean)
outlet_pivot_df
[41]:
channel
city_outlet
Ahmedabad - Bodakdev
brand
Bowl_Meals
Fast_Food
North_Indian_Meals
Thali_Meals
Ahmedabad - Chandkheda Bowl_Meals
Fast_Food
North_Indian_Meals
Thali_Meals
Baroda - Alkapuri
Bowl_Meals
Fast_Food
North_Indian_Meals
Thali_Meals
Indore- Vijaynagar
Bowl_Meals
Fast_Food
North_Indian_Meals
Jaipur - Vaishali Nagar Bowl_Meals
Fast_Food
North_Indian_Meals
Maharashtra- Nagpur
Bowl_Meals
Fast_Food
North_Indian_Meals
Pune -Kharadi
Bowl_Meals
Fast_Food
North_Indian_Meals
Thali_Meals
Surat - Vesu
Bowl_Meals
Fast_Food
North_Indian_Meals
total
App/Web
Swiggy
Zomato
-
-
NaN-
NaN-
-
NaN-
NaN-
[42]: rels = Time_pivot_df.to_excel('Tealbox_pivot_df_time.xlsx')
40
[43]: pels = outlet_pivot_df.to_excel('Tealbox_outlet.xlsx')
[44]: df.payment_type.value_counts()
[44]: Online
31579
Cash
847
UPI
389
123
CARD
Name: payment_type, dtype: int64
[45]: df_swiggy.info()
DatetimeIndex: 17089 entries,-:14:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
brand
17089 non-null object
1
invoice_no
17089 non-null int64
2
payment_type
17089 non-null object
3
status
17089 non-null object
4
channel
17089 non-null object
5
my_amount
17089 non-null int64
6
total_tax
17089 non-null float64
7
discount
17089 non-null float64
8
container_charge 17089 non-null int64
9
total
17089 non-null int64
10 item_name
17089 non-null object
11 category_name
17089 non-null object
12 item_price
17089 non-null int64
13 item_quantity
17089 non-null int64
14 item_total
17089 non-null int64
15 req_hour
17089 non-null int64
16 day_of_week
17089 non-null object
17089 non-null object
17 city_outlet
18 Timeslot
16377 non-null category
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 2.5+ MB
[46]: df.channel.value_counts()
[46]: Swiggy
17089
Zomato
14694
App/Web
1155
Name: channel, dtype: int64
41
[47]: plt.figure(figsize=(8,6))
sizes = df.channel.value_counts()
# Setting labels for items in Chart
labels = ['Swiggy', 'Zomato', 'Others']
# colors
colors = ['#FF0000', '#0000FF',
'#ADFF2F']
# explosion
explode = (0.0, 0.0,0.0)
# Pie Chart
plt.pie(sizes, colors=colors, labels=labels,
autopct='%1.1f%%', pctdistance=0.85,
explode=explode)
# draw circle
centre_circle = plt.Circle((0, 0), 0.70, fc='white')
fig = plt.gcf()
# Adding Circle in Pie chart
fig.gca().add_artist(centre_circle)
# Adding Title of chart
plt.title('Favourite brand of food for swiggy customers')
# Add Legends
#plt.legend(labels, loc="lower left")
# Displaying Chart
plt.show()
42
[48]: plt.figure(figsize=(8,6))
sizes = df_swiggy.brand.value_counts()
# Setting labels for items in Chart
labels = ['Bowl_Meals', 'North_Indian_Meals', 'Fast_Food', 'Thali_Meals']
# colors
colors = ['#FF0000', '#0000FF', '#FFFF00', '#ADFF2F']
# explosion
explode = (0.0, 0.0, 0.0, 0.0)
# Pie Chart
plt.pie(sizes, colors=colors, labels=labels,
autopct='%1.1f%%', pctdistance=0.85,
explode=explode)
# draw circle
43
centre_circle = plt.Circle((0, 0), 0.70, fc='white')
fig = plt.gcf()
# Adding Circle in Pie chart
fig.gca().add_artist(centre_circle)
# Adding Title of chart
plt.title('Favourite brand of food for swiggy customers')
# Add Legends
#plt.legend(labels, loc="lower left")
# Displaying Chart
plt.show()
[49]: plt.figure(figsize=(8,6))
sizes = df_zomato.brand.value_counts()
44
# Setting labels for items in Chart
#labels = ['Bowl_Meals', 'North_Indian_Meals', 'Fast_Food', 'Thali_Meals']
# colors
colors = ['#FF0000', '#0000FF', '#FFFF00', '#ADFF2F']
# explosion
explode = (0.0, 0.0, 0.0, 0.0)
# Pie Chart
plt.pie(sizes, colors=colors, labels=labels,
autopct='%1.1f%%', pctdistance=0.85,
explode=explode)
# draw circle
centre_circle = plt.Circle((0, 0), 0.70, fc='white')
fig = plt.gcf()
# Adding Circle in Pie chart
fig.gca().add_artist(centre_circle)
# Adding Title of chart
plt.title('Favourite brand of food for zomato customers')
# Add Legends
#plt.legend(labels, loc="lower left")
# Displaying Chart
plt.show()
45
[50]: #now plotting for requests per hour according to status
plt.figure(figsize=(18,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='city_outlet',y='total',hue='brand',data=df_swiggy,estimator = np.
↪mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 2)), fontsize=14, color='black',
rotation=0)
plt.title("Mean Order value for each Brand from each Outlet for Swiggy",␣
↪fontsize= 14)
plt.ylabel("Price")
plt.xticks(rotation = 90, fontsize = 14)
plt.show()
posx and posy should be finite values
46
posx
posx
posx
posx
posx
posx
posx
posx
posx
posx
posx
and
and
and
and
and
and
and
and
and
and
and
posy
posy
posy
posy
posy
posy
posy
posy
posy
posy
posy
should
should
should
should
should
should
should
should
should
should
should
be
be
be
be
be
be
be
be
be
be
be
finite
finite
finite
finite
finite
finite
finite
finite
finite
finite
finite
values
values
values
values
values
values
values
values
values
values
values
[51]: #plots of frquency of request
plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Baroda␣
↪- Alkapuri')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Baroda -␣
↪Alkapuri'")
47
plt.ylabel("Price")
[51]: Text(0, 0.5, 'Price')
[52]: plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Indore-␣
↪Vijaynagar')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Indore-␣
↪Vijaynagar'")
plt.ylabel("Price")
[52]: Text(0, 0.5, 'Price')
48
[53]: plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Ahmedabad␣
↪- Chandkheda')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Ahmedabad -␣
↪Chandkheda'")
plt.ylabel("Price")
[53]: Text(0, 0.5, 'Price')
posx
posx
posx
posx
and
and
and
and
posy
posy
posy
posy
should
should
should
should
be
be
be
be
finite
finite
finite
finite
values
values
values
values
49
[54]: plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Pune␣
↪-Kharadi')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Pune -Kharadi'")
plt.ylabel("Price")
[54]: Text(0, 0.5, 'Price')
posx
posx
posx
posx
and
and
and
and
posy
posy
posy
posy
should
should
should
should
be
be
be
be
finite
finite
finite
finite
values
values
values
values
50
[55]: #plots of frquency of request
plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Ahmedabad␣
↪- Bodakdev')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Ahmedabad -␣
↪Bodakdev'")
plt.ylabel("Price")
[55]: Text(0, 0.5, 'Price')
51
[56]: #plots of frquency of request
plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Jaipur␣
↪- Vaishali Nagar')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Jaipur - Vaishali␣
↪Nagar'")
plt.ylabel("Price")
[56]: Text(0, 0.5, 'Price')
52
[57]: #plots of frquency of request
plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Surat␣
↪- Vesu')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Surat - Vesu'")
plt.ylabel("Price")
[57]: Text(0, 0.5, 'Price')
53
[58]: #plots of frquency of request
plt.figure(figsize=(12,6),dpi=80,facecolor='y',edgecolor='k')
fig = sns.
↪barplot(x='brand',y='total',hue='channel',data=df[(df['city_outlet']=='Maharashtra-␣
↪Nagpur')],estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each channel for Maharashtra-␣
↪Nagpur'")
plt.ylabel("Price")
[58]: Text(0, 0.5, 'Price')
54
[59]: df_swiggy.info()
DatetimeIndex: 17089 entries,-:14:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
brand
17089 non-null object
1
invoice_no
17089 non-null int64
2
payment_type
17089 non-null object
3
status
17089 non-null object
4
channel
17089 non-null object
5
my_amount
17089 non-null int64
6
total_tax
17089 non-null float64
7
discount
17089 non-null float64
8
container_charge 17089 non-null int64
9
total
17089 non-null int64
10 item_name
17089 non-null object
11 category_name
17089 non-null object
12 item_price
17089 non-null int64
13 item_quantity
17089 non-null int64
14 item_total
17089 non-null int64
15 req_hour
17089 non-null int64
16 day_of_week
17089 non-null object
17 city_outlet
17089 non-null object
18 Timeslot
16377 non-null category
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 2.5+ MB
55
[60]: #plots of frquency of request
plt.figure(figsize=(18,8), facecolor='y', edgecolor='r')
fig = sns.
↪barplot(hue='brand',y='total',x='city_outlet',data=df_swiggy,estimator=np.
↪mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation = 90, fontsize = 14)
plt.title("'Mean Order value for each Brand each outlet for diff outlets for␣
↪swiggy'", fontsize = 15)
plt.ylabel("Price")
plt.show()
posx
posx
posx
posx
posx
posx
posx
posx
posx
posx
posx
posx
and
and
and
and
and
and
and
and
and
and
and
and
posy
posy
posy
posy
posy
posy
posy
posy
posy
posy
posy
posy
should
should
should
should
should
should
should
should
should
should
should
should
be
be
be
be
be
be
be
be
be
be
be
be
finite
finite
finite
finite
finite
finite
finite
finite
finite
finite
finite
finite
values
values
values
values
values
values
values
values
values
values
values
values
56
[61]: #plots of frquency of request
plt.figure(figsize=(18,8), facecolor='y', edgecolor='r')
fig = sns.
↪barplot(hue='brand',y='total',x='city_outlet',data=df_zomato,estimator=np.
↪mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=14, color='black',
rotation=0)
plt.xticks(rotation = 90, fontsize = 14)
plt.title("'Mean Order value for each Brand each outlet for diff outlets for␣
↪Zomato'", fontsize = 15)
plt.ylabel("Price")
plt.show()
posx
posx
posx
posx
posx
and
and
and
and
and
posy
posy
posy
posy
posy
should
should
should
should
should
be
be
be
be
be
finite
finite
finite
finite
finite
values
values
values
values
values
57
posx
posx
posx
posx
posx
posx
posx
and
and
and
and
and
and
and
posy
posy
posy
posy
posy
posy
posy
should
should
should
should
should
should
should
be
be
be
be
be
be
be
finite
finite
finite
finite
finite
finite
finite
values
values
values
values
values
values
values
[63]: df.brand.value_counts()
[63]: Bowl_Meals
13594
North_Indian_Meals
12828
Fast_Food
5261
Thali_Meals
1255
Name: brand, dtype: int64
[69]: #plots of frquency of request
plt.figure(figsize=(18,8), facecolor='y', edgecolor='r')
fig = sns.barplot(hue='brand',y='total',x='channel',data=df,estimator=np.mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
58
str(round((i.get_height()), 0)), fontsize=14, color='black',
rotation=0)
plt.title("'Mean Order value for each Brand each outlet for diff channels'",␣
↪fontsize = 15)
plt.ylabel("Price")
plt.show()
[74]: df.info()
DatetimeIndex: 32938 entries,-:10:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
brand
32938 non-null object
1
invoice_no
32938 non-null int64
2
payment_type
32938 non-null object
3
status
32938 non-null object
4
channel
32938 non-null object
5
my_amount
32938 non-null int64
6
total_tax
32938 non-null float64
7
discount
32938 non-null float64
8
container_charge 32938 non-null int64
9
total
32938 non-null int64
10 item_name
32938 non-null object
11 category_name
32938 non-null object
12 item_price
32938 non-null int64
13 item_quantity
32938 non-null int64
14 item_total
32938 non-null int64
59
15 req_hour
32938 non-null int64
16 day_of_week
32938 non-null object
17 city_outlet
32938 non-null object
30366 non-null category
18 Timeslot
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 4.8+ MB
[88]: #plots of frquency of request
plt.figure(figsize=(8,8),dpi=80,facecolor='cyan',edgecolor='k')
fig = sns.countplot(x='channel', hue = 'brand',data=df)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'No of Order for diff brand of food for diff channels'")
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.ylabel("Price")
[88]: Text(0, 0.5, 'Price')
60
[93]: df.brand.value_counts()
[93]: Bowl_Meals
13594
North_Indian_Meals
12828
Fast_Food
5261
Thali_Meals
1255
Name: brand, dtype: int64
[96]:
No handles with labels found to put in legend.
[96]: Text(0, 0.5, 'Price')
61
[99]: #plots of frquency of request
plt.figure(figsize=(12,10),dpi=80,facecolor='cyan',edgecolor='k')
fig = sns.barplot(x =␣
↪'category_name',y='total',data=df_zomato[(df_zomato['brand']=='North_Indian_Meals')],estimat
↪mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
62
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for diff category in Bowl meals for Zomato'")
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.xticks(rotation= 90, fontsize =10)
plt.ylabel("Price")
No handles with labels found to put in legend.
[99]: Text(0, 0.5, 'Price')
63
[103]: #plots of frquency of request
plt.figure(figsize=(12,6),dpi=80,facecolor='cyan',edgecolor='k')
fig = sns.barplot(x = 'channel',hue = 'Timeslot',y='total',data=df,estimator=np.
↪mean)
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'Mean Order value for diff Timeslots for all the channels'")
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.xticks( fontsize =10)
plt.ylabel("Price")
[103]: Text(0, 0.5, 'Price')
[100]: df.info()
DatetimeIndex: 32938 entries,-:10:00 to-:49:00
Data columns (total 19 columns):
#
Column
Non-Null Count Dtype
--- ------------------- ----0
brand
32938 non-null object
1
invoice_no
32938 non-null int64
2
payment_type
32938 non-null object
64
3
status
32938 non-null object
4
channel
32938 non-null object
5
my_amount
32938 non-null int- non-null float64
6
total_tax
7
discount
32938 non-null float64
8
container_charge 32938 non-null int64
9
total
32938 non-null int64
10 item_name
32938 non-null object
11 category_name
32938 non-null object
12 item_price
32938 non-null int64
13 item_quantity
32938 non-null int64
14 item_total
32938 non-null int64
15 req_hour
32938 non-null int64
16 day_of_week
32938 non-null object
17 city_outlet
32938 non-null object
18 Timeslot
30366 non-null category
dtypes: category(1), float64(2), int64(8), object(8)
memory usage: 4.8+ MB
[104]: df_zomato.brand.value_counts()
[104]: North_Indian_Meals
6236
Bowl_Meals
5274
Fast_Food
2736
Thali_Meals
448
Name: brand, dtype: int64
[115]: percent = round(df_zomato.brand.value_counts())
sub=['North_Indian_Meals','Bowl_Meals','Fast_Food','Thali_Meals']
plt.axis("equal")
plt.pie(percent,labels= sub ,radius=1.6,autopct='%1.2f%%',explode=[0.01,0.01,0.
↪01,0.01],startangle=90,shadow=True,counterclock=False,pctdistance=0.6)
plt.show()
65
[136]: #plots of frquency of request
plt.figure(figsize=(10,6),dpi=80,facecolor='cyan',edgecolor='k')
fig = sns.countplot(x =␣
↪'category_name',data=df_zomato[(df_zomato['brand']=='North_Indian_Meals')])
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'No of Order for diff category in North_Indian_Meals for Zomato'")
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.xticks(rotation= 90, fontsize =10)
plt.ylabel("Price")
No handles with labels found to put in legend.
[136]: Text(0, 0.5, 'Price')
66
[119]: percent = round(df_swiggy.brand.value_counts())
sub=['Bowl_Meals', 'North_Indian_Meals','Fast_Food','Thali_Meals']
plt.axis("equal")
plt.pie(percent,labels= sub ,radius=1.6,autopct='%1.2f%%',explode=[0.01,0.01,0.
↪01,0.01],startangle=90,shadow=True,counterclock=False,pctdistance=0.6)
plt.show()
67
[137]: #plots of frquency of request
plt.figure(figsize=(10,6),dpi=80,facecolor='cyan',edgecolor='k')
fig = sns.countplot(x =␣
↪'category_name',data=df_swiggy[(df_swiggy['brand']=='Bowl_Meals')])
for i in fig .patches:
# get_x pulls left or right; get_height pushes up or down
fig.text(i.get_x()+.01, i.get_height()+0.2, \
str(round((i.get_height()), 0)), fontsize=10, color='black',
rotation=0)
plt.title("'No of Order for diff category in Bowl_Meals for Swiggy'")
plt.legend(loc=2,shadow=True,fontsize='medium')
plt.xticks(rotation= 90, fontsize =10)
plt.ylabel("Price")
No handles with labels found to put in legend.
[137]: Text(0, 0.5, 'Price')
68
[ ]:
df_swiggy.discount.describe()
[134]: plt.figure(figsize=(6,5))
ax = sns.distplot(df_swiggy['discount'], hist=True)
plt.show()
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
69
[135]: plt.figure(figsize=(6,5))
ax = sns.distplot(df_zomato['discount'], hist=True)
plt.show()
C:\Users\Lenovo\anaconda3\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a
future version. Please adapt your code to use either `displot` (a figure-level
function with similar flexibility) or `histplot` (an axes-level function for
histograms).
warnings.warn(msg, FutureWarning)
70
[ ]:
71