Plotting chicken locations
Now you will create a scatterplot that shows where the Nashville chickens are!
This exercise is part of the course
Visualizing Geospatial Data in Python
Exercise instructions
- The path to the chicken dataset is in the variable
chickens_path
. Use theread_csv
function of pandas to load it into a DataFrame calledchickens
. - Use the
.head()
function to look at the first few rows. - Next add the x and y arguments to
plt.scatter()
to plot the locations of the Nashville chickens. Use the default marker and color options. - Show the plot using
plt.show()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import pandas and matplotlib.pyplot using their customary aliases
import pandas as pd
import matplotlib.pyplot as plt
# Load the dataset
chickens = pd.____(chickens_path)
# Look at the first few rows of the chickens DataFrame
print(chickens.____())
# Plot the locations of all Nashville chicken permits
plt.scatter(x = chickens.____, y = chickens.____)
# Show the plot
plt.show()