Deleting with np.delete()
What if your tree research focuses only on living trees on publicly-owned city blocks? It might be helpful to delete some unneeded data like the stump diameter column and some trees located on private blocks.
You've learned that NumPy's np.delete()
function takes three arguments: the original array, the index or indices to be deleted, and the axis to delete along. If you don't know the index or indices of the array you'd like to delete, recall that when it is only passed one argument,np.where()
returns an array of indices where a condition is met!
numpy
is loaded as np
, and the tree_census
2D array is available. The columns in order refer to a tree's ID, block number, trunk diameter, and stump diameter.
This exercise is part of the course
Introduction to NumPy
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Delete the stump diameter column from tree_census
tree_census_no_stumps = ____
# Save the indices of the trees on block 313879
private_block_indices = ____