Skip to content

Instantly share code, notes, and snippets.

@akrisanov
Created July 11, 2018 00:24
Show Gist options
  • Save akrisanov/52c44b91d9e0d10535299480b1fd7bda to your computer and use it in GitHub Desktop.
Save akrisanov/52c44b91d9e0d10535299480b1fd7bda to your computer and use it in GitHub Desktop.
DataCamp: Intro to Python for Data Science https://www.datacamp.com/courses/intro-to-python-for-data-science
# heights and positions are available as lists
# Import numpy
import numpy as np
# Convert positions and heights to numpy arrays: np_positions, np_heights
np_positions = np.array(positions)
np_heights = np.array(heights)
# Heights of the goalkeepers: gk_heights
gk_heights = np_heights[np_positions == 'GK']
# Heights of the other players: other_heights
other_heights = np_heights[np_positions != 'GK']
# Print out the median height of goalkeepers. Replace 'None'
print("Median height of goalkeepers: " + str(np.median(gk_heights)))
# Print out the median height of other players. Replace 'None'
print("Median height of other players: " + str(np.median(other_heights)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment