pandas correlation,visualization 5
pandas correlation,visualization 5
import numpy as np
import matplotlib.pyplot as plt
import sklearn
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
Finding Relationships
A great aspect of the Pandas module is the corr() method.
The corr() method calculates the relationship between each column in your data set.
In [3]: df.corr()
Out[4]: Calories
Calories 1.000000
Duration 0.922717
Maxpulse 0.203813
Pulse 0.025121
In [6]: df.plot()
plt.show()
Histogram
In [7]: df.Maxpulse.plot.hist(figsize=(10,10),cmap='brg');
In [8]: #boxplot
In [11]: df.plot.box(figsize=(22,4),subplots=True);
In [12]: #histogram
In [13]: df.plot.hist(figsize=(6,18),subplots=True);
In [14]: #line
In [15]: df.plot.line(figsize=(6,18),subplots=True);
In [16]: df.Maxpulse.plot.line(figsize=(4,3), cmap='gist_earth');
In [17]: df.columns
Index(['Duration', 'Pulse', 'Maxpulse', 'Calories'], dtype='object')
Out[17]:
In [18]: #bar
In [23]: df.sort_values(by='Pulse')[:5].plot.barh('Calories','Pulse',figsize=(6,4));
In [24]: #scatter
In [25]: #pie
In [26]: #kde
In [27]: #hexbin
In [ ]: