<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 display the first three animals
Step1:  Sort the animals to see the 3 longest animals
Step2:  What are the counts of the different values of the "animal" column? a.k.a. how many cats and how many dogs
Step3:  Only select the dogs
Step4:  Display all of the animals that are greater than 40 cm
Step5:  'length' is the animal's length in cm. Create a new column called inches that is the length in inches
Step6:  Save the cats to a separate variable called "cats." Save the dogs to a separate variable called "dogs."
Step7:  Display all of the animals that are cats and above 12 inches long. First do it using the "cats" variable, then do it using your normal dataframe.
Step8:  What's the mean length of a cat?
Step9:  What's the mean length of a dog?
Step10:  Use groupby to accomplish both of the above tasks at once.
Step11:  Make a histogram of the length of dogs. I apologize that it is so boring
Step12:  Change your graphing style to be something else (anything else!)
Step13:  Make a horizontal bar graph of the length of the animals, with their name as the label (look at the billionaires notebook I put on Slack!)
Step14:  Make a sorted horizontal bar graph of the cats, with the larger cats on top
<ASSISTANT_TASK:>
Python Code:
columns_to_show = ['animal','name','length']
df[columns_to_show][0:3]
Explanation: display the first three animals
End of explanation
df.sort_values(by='length', ascending=False).head(3) #sort_values, not sort, and sort by length column
Explanation: Sort the animals to see the 3 longest animals
End of explanation
df['animal'].value_counts() #value_counts()
Explanation: What are the counts of the different values of the "animal" column? a.k.a. how many cats and how many dogs
End of explanation
is_dog = df['animal']=='dog'
df[df['animal'] == 'dog'] #df['animal]==dog will only give a list of true or false, if you want the rows back, you have to put a df[] to put the is_dog into a data frame 
Explanation: Only select the dogs
End of explanation
df[df['length'] > 40]
Explanation: Display all of the animals that are greater than 40 cm
End of explanation
df['inches']=df['length']/2.54
df
Explanation: 'length' is the animal's length in cm. Create a new column called inches that is the length in inches
End of explanation
dogs=df['animal'] == 'dog'
cats=df['animal'] == 'cat'
Explanation: Save the cats to a separate variable called "cats." Save the dogs to a separate variable called "dogs."
End of explanation
df[(df['animal'] =='cat') & (df['inches']>12)] #panda only recognizes the conditions in parentaces
Explanation: Display all of the animals that are cats and above 12 inches long. First do it using the "cats" variable, then do it using your normal dataframe.
End of explanation
df[cats].describe()
#the mean length of a cat is 37.33333
Explanation: What's the mean length of a cat?
End of explanation
df[dogs].describe()
# the mean length of a dog is 50inches
Explanation: What's the mean length of a dog?
End of explanation
df.groupby([cats,dogs]).describe()
Explanation: Use groupby to accomplish both of the above tasks at once.
End of explanation
new_dog_data = df[df['animal'] == 'dog']
new_dog_data['length'].hist()
Explanation: Make a histogram of the length of dogs. I apologize that it is so boring
End of explanation
plt.style.use('ggplot')
new_dog_data['length'].hist()
Explanation: Change your graphing style to be something else (anything else!)
End of explanation
df.plot(kind='barh', x='name',y='length') #length='false' remove the length #barh: a hornizontal bar chat
Explanation: Make a horizontal bar graph of the length of the animals, with their name as the label (look at the billionaires notebook I put on Slack!)
End of explanation
df[df['animal']== 'cat'].sort_values(by='length').plot(kind='barh', x='name', y='length')
Explanation: Make a sorted horizontal bar graph of the cats, with the larger cats on top
End of explanation
<END_TASK>