ComeçarComece de graça

Digging in with basic transforms

You are curious to see if the population of a state correlates to the number of items sold at farmer's markets. To check this, take the log of the population and draw a scatter plot against the number of items sold by a market. From your previous explorations of the dataset, you know there will be a lot of overlap, so to get a better handle on the patterns you want to reduce the marker opacity.

Este exercício faz parte do curso

Improving Your Data Visualizations in Python

Ver curso

Instruções do exercício

  • Use numpy (imported as np) to create a new column: log_pop by taking the log of the state population.
  • Pass this newly created logged column to the scatter plot function's x-mapping.
  • Set the scatter plot's opacity to 25% to show overlap.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Create a new logged population column 
markets['____'] = np.____(markets['____'])

# Draw a scatterplot of log-population to # of items sold
sns.scatterplot(x = '____', 
                  y = 'num_items_sold', 
                  # Reduce point opacity to show overlap
                  ____ = ____, 
                  data = markets)

plt.show()
Editar e executar o código