Saturday, November 30, 2019

Learning Datascience Day8


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]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d2f5add8>

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]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d437c8d0>

In [10]:
plt.figure(figsize=(10,10))
sns.countplot(x=tips['day'],data=tips)
Out[10]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d2ef5710>

In [11]:
sns.countplot(x=tips['tip'],data=tips)
Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d43d07f0>

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]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d489f1d0>

In [15]:
sns.boxplot(x='day',y='total_bill',data=tips)
Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d492ce10>

In [16]:
sns.violinplot(x='sex',y='total_bill',data=tips)
Out[16]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d497b160>

In [17]:
sns.violinplot(x='day',y='total_bill',data=tips)
Out[17]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d49f8588>

In [18]:
sns.violinplot(x='day',y='total_bill',data=tips,hue='time')
Out[18]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4a695f8>

In [21]:
sns.violinplot(x='day',y='total_bill',data=tips,hue='time',split='time')
Out[21]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4b1a8d0>

In [22]:
sns.stripplot(x='sex',y='total_bill',data=tips)
Out[22]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4bcc5f8>

In [23]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=False)
Out[23]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4c0cef0>

In [24]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=True)
Out[24]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4c5ae48>

In [25]:
sns.stripplot(x='day',y='total_bill',data=tips,jitter=False)
Out[25]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4cb9b38>

In [26]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=True)
Out[26]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4c0cac8>

In [27]:
sns.stripplot(x='sex',y='total_bill',data=tips,jitter=True,hue='smoker')
Out[27]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4d70a20>

In [28]:
sns.stripplot(x='day',y='total_bill',data=tips,jitter=True,hue='sex')
Out[28]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4dd2c18>

In [30]:
sns.swarmplot(x='day',y='total_bill',data=tips)
Out[30]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4e83f60>

In [31]:
sns.swarmplot(x='day',y='total_bill',data=tips,hue='sex')
Out[31]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4ed78d0>

In [33]:
sns.violinplot(x='tip',y='day',data=tips)
sns.swarmplot(x='tip',y='day',data=tips,color='white')
Out[33]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d4ec6f98>

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]:
<matplotlib.axes._subplots.AxesSubplot at 0x172d605b390>

In [ ]:





Featured Post

Ichimoku cloud

Here how you read a ichimoku cloud 1) Blue Converse line: It measures short term trend. it also shows minor support or resistance. Its ve...