/ Python And R Data science skills: 94 seaborn exercise in telugu public

Sunday, 18 February 2018

94 seaborn exercise in telugu public

94 seaborn exercise in telugu public

how to import seaborn

how to load data set titanic

how to import mtplot lib

In [6]:
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
sns.set_style('whitegrid')
titanic = sns.load_dataset('titanic')
In [39]:
#titanic.head(7)
In [5]:
# watch  5 rows in data set
In [7]:
 
Out[7]:
<seaborn.axisgrid.JointGrid at 0xb1e0f98>
In [40]:
sns.jointplot(x='fare',y='age',data=titanic)
Out[40]:
<seaborn.axisgrid.JointGrid at 0xe8f46d8>
In [9]:
 
Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0xbf65518>
In [41]:
sns.distplot(titanic['fare'])
Out[41]:
<matplotlib.axes._subplots.AxesSubplot at 0xea861d0>
In [42]:
sns.distplot(titanic['fare'],kde=False)
Out[42]:
<matplotlib.axes._subplots.AxesSubplot at 0xeaf1550>
In [43]:
sns.distplot(titanic['fare'],kde=False,color="r")
Out[43]:
<matplotlib.axes._subplots.AxesSubplot at 0xeb6d2b0>
In [47]:
sns.distplot(titanic['fare'],kde=False,color="r",bins=130)
Out[47]:
<matplotlib.axes._subplots.AxesSubplot at 0xedc2518>
In [16]:
 
Out[16]:
<matplotlib.axes._subplots.AxesSubplot at 0xc3229b0>
In [49]:
sns.boxplot(x='class',y='age',data=titanic)
Out[49]:
<matplotlib.axes._subplots.AxesSubplot at 0xf0df128>
In [50]:
sns.boxplot(x='class',y='age',data=titanic,palette='rainbow')
Out[50]:
<matplotlib.axes._subplots.AxesSubplot at 0x1012a588>
In [22]:
 
Out[22]:
<matplotlib.axes._subplots.AxesSubplot at 0xc52d908>
In [51]:
sns.swarmplot(x='class',y='age',data=titanic)
Out[51]:
<matplotlib.axes._subplots.AxesSubplot at 0x10167c88>
In [52]:
sns.swarmplot(x='class',y='age',data=titanic,palette='Set2')
Out[52]:
<matplotlib.axes._subplots.AxesSubplot at 0x101b69b0>
In [27]:
 
Out[27]:
<matplotlib.axes._subplots.AxesSubplot at 0xc4137f0>
In [53]:
sns.countplot(x='sex',data=titanic)
Out[53]:
<matplotlib.axes._subplots.AxesSubplot at 0x10234828>
In [29]:
 
Out[29]:
Text(0.5,1,'titanic.corr()')
In [55]:
titanic.corr()
#sns.heatmap(titanic.corr(),cmap='coolwarm')
Out[55]:
survived pclass age sibsp parch fare adult_male alone
survived 1.000000 -0.338481 -0.077221 -0.035322 0.081629 0.257307 -0.557080 -0.203367
pclass -0.338481 1.000000 -0.369226 0.083081 0.018443 -0.549500 0.094035 0.135207
age -0.077221 -0.369226 1.000000 -0.308247 -0.189119 0.096067 0.280328 0.198270
sibsp -0.035322 0.083081 -0.308247 1.000000 0.414838 0.159651 -0.253586 -0.584471
parch 0.081629 0.018443 -0.189119 0.414838 1.000000 0.216225 -0.349943 -0.583398
fare 0.257307 -0.549500 0.096067 0.159651 0.216225 1.000000 -0.182024 -0.271832
adult_male -0.557080 0.094035 0.280328 -0.253586 -0.349943 -0.182024 1.000000 0.404744
alone -0.203367 0.135207 0.198270 -0.584471 -0.583398 -0.271832 0.404744 1.000000
In [56]:
sns.heatmap(titanic.corr(),cmap='coolwarm')
#plt.title('titanic.corr()')
Out[56]:
<matplotlib.axes._subplots.AxesSubplot at 0x10515ef0>
In [33]:
 
Out[33]:
<seaborn.axisgrid.FacetGrid at 0xde032e8>
In [57]:
g = sns.FacetGrid(data=titanic,col='sex')
#g.map(plt.hist,'age')
In [58]:
g = sns.FacetGrid(data=titanic,col='sex')
g.map(plt.hist,'age')
Out[58]:
<seaborn.axisgrid.FacetGrid at 0x1060dcc0>

No comments:

Post a Comment