MulaiMulai sekarang secara gratis

Plotting chicken locations

Now you will create a scatterplot that shows where the Nashville chickens are!

Latihan ini adalah bagian dari kursus

Visualizing Geospatial Data in Python

Lihat Kursus

Petunjuk latihan

  • The path to the chicken dataset is in the variable chickens_path. Use the read_csv function of pandas to load it into a DataFrame called chickens.
  • 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().

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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()
Edit dan Jalankan Kode