Professional Documents
Culture Documents
B 4 Tips
B 4 Tips
B 4 Tips
In [45]: #
In [47]: df = pd.read_csv('tips_DV.csv')
In [48]: df
In [50]: df.isna().sum()
total_bill 0
Out[50]:
tip 0
sex 0
smoker 0
day 0
time 0
peoples 0
dtype: int64
for i in col_var:
print(i, df[i].unique())
peoples [2 3 4 1 6 5]
sex ['Female' 'Male']
smoker ['No' 'Yes']
day ['Sun' 'Sat' 'Thur' 'Fri']
time ['Dinner' 'Lunch']
In [52]: df.columns
Plots
In [53]: import seaborn as sns
import matplotlib.pyplot as plt
In [55]: sns.pairplot(df)
C:\Users\Admin\anaconda3\Lib\site-packages\seaborn\axisgrid.py:118: UserWarning: T
he figure layout has changed to tight
self._figure.tight_layout(*args, **kwargs)
<seaborn.axisgrid.PairGrid at 0x1389bd5be10>
Out[55]:
Line Plots
In [56]: sns.lineplot(df,x='total_bill',y='tip')
# Tip increases as Totl_bill increases
In [57]: sns.lineplot(df,x='peoples',y='tip')
# Tip increases as no of people increases
In [58]: sns.lineplot(df,x='peoples',y='tip',hue='time')
# higher tip at lauch time as compared to Dinner
Box Plots
In [59]: sns.boxplot(df,x='day',y='total_bill')
In [60]: sns.boxplot(df,x='peoples',y='total_bill',hue='day')
In [61]: sns.boxplot(df,x='day',y='total_bill',hue='sex')
Histogram
In [62]: sns.histplot(df,x='total_bill',hue='time')
In [63]: sns.histplot(df,x='tip',hue='sex')
In [64]: sns.histplot(df,x='tip',hue='smoker')
Scatter Plots
In [65]: sns.scatterplot(df,x='total_bill',y='tip',hue='time')
In [66]: sns.scatterplot(df,x='total_bill',y='tip',hue='smoker')
Violen
localhost:8888/nbconvert/html/Desktop/DSBDA GROP B/Assignment 4/B_4_Tips.ipynb?download=false 8/10
4/14/24, 10:13 AM B_4_Tips
In [ ]:
In [ ]: