In [1]:
import numpy as np
import pandas as
pd
In [2]:
import matplotlib.pyplot
as plt
import seaborn as
sns
tips=sns.load_dataset('tips')
In [4]:
#in the below
example we are ploting count. Countplot is for counting
In [5]:
sns.countplot(x=tips['sex'],data=tips)
Out[5]:
In [7]:
tips['sex'].value_counts()
Out[7]:
Male 157
Female 87
Name: sex, dtype: int64
In [8]:
sns.countplot(x=tips['day'],data=tips)
Out[8]:
In [10]:
plt.figure(figsize=(10,10))
sns.countplot(x=tips['day'],data=tips)
Out[10]:
In [11]:
sns.countplot(x=tips['tip'],data=tips)
Out[11]:
In [12]:
tips['tip'].value_counts()
Out[12]:
2.00 33
3.00 23
4.00 12
5.00 10
2.50 10
3.50 9
1.50 9
1.00 4
1.25 3
3.48 3
2.01 2
4.08 2
2.23 2
2.03 2
3.18 2
2.31 2
2.24 2
6.50 2
4.30 2
2.20 2
3.76 2
3.25 2
2.75 2
1.44 2
3.23 2
1.01 1
2.45 1
1.47 1
3.61 1
2.54 1
..
4.06 1
3.15 1
1.45 1
2.34 1
1.92 1
2.30 1
2.88 1
3.55 1
4.20 1
4.19 1
2.56 1
2.71 1
3.27 1
5.14 1
2.02 1
4.67 1
4.34 1
5.17 1
3.14 1
5.15 1
1.67 1
1.32 1
1.36 1
1.68 1
1.83 1
2.83 1
1.58 1
3.71 1
3.35 1
2.18 1
Name: tip, Length: 123, dtype:
int64
In [13]:
#now we will do
box plot
In [14]:
sns.boxplot(x='sex',y='total_bill',data=tips)
Out[14]:
In [15]:
sns.boxplot(x='day',y='total_bill',data=tips)
Out[15]:
In [16]:
sns.violinplot(x='sex',y='total_bill',data=tips)
Out[16]:
In [17]:
sns.violinplot(x='day',y='total_bill',data=tips)
Out[17]:
In [18]:
sns.violinplot(x='day',y='total_bill',data=tips,hue='time')
Out[18]:
In [21]:
sns.violinplot(x='day',y='total_bill',data=tips,hue='time',split='time')
Out[21]:
In [22]:
sns.stripplot(x='sex',y='total_bill',data=tips)
Out[22]:
In [23]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=False)
Out[23]:
In [24]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=True)
Out[24]:
In [25]:
sns.stripplot(x='day',y='total_bill',data=tips,jitter=False)
Out[25]:
In [26]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=True)
Out[26]:
In [27]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=True,hue='smoker')
Out[27]:
In [28]:
sns.stripplot(x='day',y='total_bill',data=tips,jitter=True,hue='sex')
Out[28]:
In [30]:
sns.swarmplot(x='day',y='total_bill',data=tips)
Out[30]:
In [31]:
sns.swarmplot(x='day',y='total_bill',data=tips,hue='sex')
Out[31]:
In [33]:
sns.violinplot(x='tip',y='day',data=tips)
sns.swarmplot(x='tip',y='day',data=tips,color='white')
Out[33]:
In [34]:
#we plotted 2
graph ypgether as in above example
In [35]:
tips.corr()
Out[35]:
total_bill
|
tip
|
size
|
|
total_bill
|
1.000000
|
0.675734
|
0.598315
|
tip
|
0.675734
|
1.000000
|
0.489299
|
size
|
0.598315
|
0.489299
|
1.000000
|
In [36]:
#in the above
example, we are finding the relationship between each other and how uch
In [37]:
sns.heatmap(tips.corr())
Out[37]:
In [ ]:





















No comments:
Post a Comment