In [12]:
%matplotlib inline
import numpy as np
import pandas as pd
from scipy import stats, integrate
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
sns.set_style("whitegrid")
np.random.seed(sum(map(ord, "distributions")))
In [13]:
tips = sns.load_dataset("tips")
In [14]:
g = sns.lmplot(x="total_bill",y="tip",hue="smoker", data=tips, palette="Set1")
In [15]:
g = sns.lmplot(x="total_bill", y="tip", col="day", hue="day", data=tips, col_wrap=2, size=3)
In [16]:
x = np.random.normal(size=100)
sns.distplot(x, kde=False, rug=True)
Out[16]:
In [17]:
sns.distplot(x, bins=20, kde=False, rug=True)
Out[17]:
In [18]:
x
Out[18]:
In [19]:
len(x)
Out[19]:
In [20]:
type(x)
Out[20]:
In [22]:
np.shape(x)
Out[22]:
In [23]:
sns.kdeplot(x, shade=True)
Out[23]:
In [24]:
y = np.random.gamma(6, size=200)
In [25]:
sns.distplot(x, kde=False, fit=stats.gamma)
Out[25]:
In [26]:
np.shape(y)
Out[26]:
In [36]:
rs = np.random.RandomState(10)
f, axes = plt.subplots(2, 2, figsize=(7,7), sharex=True)
d = rs.normal(size=100)
sns.distplot(d, kde=False, color="b", ax=axes[0,0])
sns.distplot(d, hist=False, color="g", kde_kws={"shade":True}, ax=axes[1,0])
sns.distplot(d, hist=False, rug=True, color="r", ax=axes[0, 1])
sns.distplot(d, color="m", ax=axes[1, 1])
plt.setp(axes, yticks=[])
plt.tight_layout()
In [28]:
In [37]:
titan = pd.read_csv('../data/titanic/train.csv')
In [38]:
titan.head()
Out[38]:
In [44]:
sns.distplot(titan['Fare'],kde=False)
Out[44]:
In [47]:
food = pd.read_csv('../data/food/openfood.tsv',sep='\t')
In [75]:
food.head(15)
Out[75]:
In [76]:
z = [x for x in food['quantity']]
print(type(z[0]))
In [54]:
food_carbon = [food['carbon-footprint_100g'] if food['carbon-footprint_100g']!= NaN]
In [55]:
x = [1,2,3]
In [64]:
y = [z*3 for z in x if z != 2]
In [65]:
y
Out[65]:
In [66]:
for yy in y:
print(yy)
In [ ]: