<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 1.Import pandas with the right name
Step1:  2. Set all graphics from matplotlib to display inline
Step2:  3. Read the csv in (it should be UTF-8 already so you don't have to worry about encoding), save it with the proper boring name
Step3:  4. Display the names of the columns in the csv
Step4:  5. Display the first 3 animals
Step5:  6. Sort the animals to see the 3 longest animals.
Step6:  7. What are the counts of the different values of the "animal" column? a.k.a. how many cats and how many dogs.
Step7:  8. Only select the dogs
Step8:  9. Display all of the animals that are greater than 40 cm.
Step9:  10. 'length' is the animal's length in cm. Create a new column called inches that is the length in inches.
Step10:  11. Save the cats to a separate variable called "cats." Save the dogs to a separate variable called "dogs."
Step11:  13. 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.
Step12:  13. What's the mean length of a cat?
Step13:  14. What's the mean length of a dog
Step14:  15. Use groupby to accomplish both of the above tasks at once.
Step15:  16. Make a histogram of the length of dogs.
Step16:  17 Change your graphing style to be something else (anything else!)
Step17:  18. Make a horizontal bar graph of the length of the animals, with their name as the label
Step18:  19. Make a sorted horizontal bar graph of the cats, with the larger cats on top.
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
Explanation: 1.Import pandas with the right name:
End of explanation
import matplotlib.pyplot as plt
%matplotlib inline
Explanation: 2. Set all graphics from matplotlib to display inline
End of explanation
df = pd.read_csv("07-hw-animals.csv")
df
Explanation: 3. Read the csv in (it should be UTF-8 already so you don't have to worry about encoding), save it with the proper boring name
End of explanation
df.columns
df.head()
Explanation: 4. Display the names of the columns in the csv
End of explanation
df['animal'].head(3)
Explanation: 5. Display the first 3 animals
End of explanation
df.sort_values('length', ascending=False).head(3)
Explanation: 6. Sort the animals to see the 3 longest animals.
End of explanation
df['animal'].value_counts()
Explanation: 7. 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
dogs = df[df['animal'] == "dog"]
dogs
Explanation: 8. Only select the dogs
End of explanation
animal_larger_40 = df['length'] > 40
animal_larger_40
df[animal_larger_40]
Explanation: 9. Display all of the animals that are greater than 40 cm.
End of explanation
df['length'].head()
inch = df['length'] * 0.393701
inch
inch = df['length'] / 2.54
inch
df['length_inch'] = inch
df.head()
Explanation: 10. '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[df['animal'] =="dog"]
dogs
cats =df[df['animal'] =="cat"]
cats
Explanation: 11. Save the cats to a separate variable called "cats." Save the dogs to a separate variable called "dogs."
End of explanation
cat = df['animal'] == "cat"
twelve_inch = df['length_inch'] > 12
df[cat & twelve_inch].head()
df[(df['animal'] == "cat") & (df['length_inch'] > 12)].head()
Explanation: 13. 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[cat].describe()
Explanation: 13. What's the mean length of a cat?
End of explanation
dog = df['animal'] == "dog"
df[dog].describe()
Explanation: 14. What's the mean length of a dog
End of explanation
df.groupby('animal').describe()
Explanation: 15. Use groupby to accomplish both of the above tasks at once.
End of explanation
dogs.hist()
Explanation: 16. Make a histogram of the length of dogs.
End of explanation
dogs.plot(kind='line')
Explanation: 17 Change your graphing style to be something else (anything else!)
End of explanation
df['length'].plot(kind='barh', x='lenth', y='name')
df['length'].plot(kind='barh', labels= df['name'])
Explanation: 18. Make a horizontal bar graph of the length of the animals, with their name as the label
End of explanation
cats =df[df['animal'] =="cat"]
cats
sort_cat = cats.sort_values('length', ascending=False)
sort_cat
sort_cat['length'].plot(kind='barh', x='length', y='name')
Explanation: 19. Make a sorted horizontal bar graph of the cats, with the larger cats on top.
End of explanation
<END_TASK>