In [1]:
import numpy as np
from numpy.random import randn
import pandas as pd

from scipy import stats

import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline

In [2]:
flights_dframe = sns.load_dataset('flights')

In [3]:
flight_dframe = flights_dframe.pivot('month', 'year', 'passengers')

In [4]:
flight_dframe


Out[4]:
year 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
month
January 112 115 145 171 196 204 242 284 315 340 360 417
February 118 126 150 180 196 188 233 277 301 318 342 391
March 132 141 178 193 236 235 267 317 356 362 406 419
April 129 135 163 181 235 227 269 313 348 348 396 461
May 121 125 172 183 229 234 270 318 355 363 420 472
June 135 149 178 218 243 264 315 374 422 435 472 535
July 148 170 199 230 264 302 364 413 465 491 548 622
August 148 170 199 242 272 293 347 405 467 505 559 606
September 136 158 184 209 237 259 312 355 404 404 463 508
October 119 133 162 191 211 229 274 306 347 359 407 461
November 104 114 146 172 180 203 237 271 305 310 362 390
December 118 140 166 194 201 229 278 306 336 337 405 432

In [5]:
sns.heatmap(flight_dframe)


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x11a0e02d0>

In [6]:
sns.heatmap(flight_dframe, annot=True, fmt='d')


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x11c84fdd0>

In [7]:
sns.heatmap(flight_dframe, center=flight_dframe.loc['January', 1955])


Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x1177e1510>

In [11]:
f, (axis1, axis2) = plt.subplots(2,1)

yearly_flights = flight_dframe.sum()

years = pd.Series(yearly_flights.index.values)
years = pd.DataFrame(years)

flights = pd.Series(yearly_flights.values)
flights = pd.DataFrame(flights)

year_dframe = pd.concat((years, flights), axis=1)

year_dframe.columns = ['Year', 'Flights']

sns.barplot('Year','Flights', data=year_dframe, ax = axis1)

sns.heatmap(flight_dframe, cmap='Blues', ax=axis2, cbar_kws={'orientation': 'horizontal'})


Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x11e56b7d0>

In [12]:
sns.clustermap(flight_dframe)


Out[12]:
<seaborn.matrix.ClusterGrid at 0x11dc64c50>

In [13]:
sns.clustermap(flight_dframe, col_cluster=False)


Out[13]:
<seaborn.matrix.ClusterGrid at 0x10709b110>

In [16]:
sns.clustermap(flight_dframe, standard_scale=1, linewidths=.5)


Out[16]:
<seaborn.matrix.ClusterGrid at 0x1208d4410>

In [17]:
sns.clustermap(flight_dframe, standard_scale=0, linewidths=.5)


Out[17]:
<seaborn.matrix.ClusterGrid at 0x1209d58d0>

In [18]:
sns.clustermap(flight_dframe, z_score=1, linewidths=.5)


Out[18]:
<seaborn.matrix.ClusterGrid at 0x121ab32d0>

In [ ]: