In [1]:
import pandas as pd
In [2]:
%matplotlib inline
In [3]:
df = pd.read_csv("07-hw-animals.csv", encoding='UTF8')
In [4]:
df
Out[4]:
In [5]:
df.columns
Out[5]:
In [6]:
df.head(3)
Out[6]:
In [9]:
df.sort_values(by='length',ascending=False).head(3)
Out[9]:
In [10]:
df['animal'].value_counts()
Out[10]:
In [12]:
df[df['animal']=='dog']
Out[12]:
In [18]:
df[df['length']>40]
Out[18]:
In [22]:
df['lengthininches']=df['length']*0.393701
In [23]:
df.head()
Out[23]:
In [24]:
cats=df[df['animal']=='cat']
In [25]:
dogs=df[df['animal']=='dog']
In [26]:
cats
Out[26]:
In [27]:
dogs
Out[27]:
In [31]:
cats[cats['lengthininches']>12]
Out[31]:
In [64]:
df[(df['animal']=='cat') & (df['lengthininches']>12)]
Out[64]:
In [46]:
cats.describe()
Out[46]:
In [47]:
dogs.describe()
Out[47]:
In [49]:
df.groupby(cats,dogs).describe()
In [50]:
dogs
Out[50]:
In [51]:
dogs['lengthininches'].hist()
Out[51]:
In [53]:
import matplotlib.pyplot as plt
In [54]:
plt.style.available
Out[54]:
In [55]:
plt.style.use('fivethirtyeight')
In [69]:
dogs.plot(kind='barh',x='name',y='length')
Out[69]:
In [79]:
catssorted=cats.sort_values(by='lengthininches')
In [80]:
catssorted.plot(kind='barh',x='name',y='length')
Out[80]:
In [ ]: