Skip to content

Instantly share code, notes, and snippets.

@naenumtou
Last active July 27, 2020 07:00
Show Gist options
  • Save naenumtou/abe1ad2f978d82b4904f19478604e718 to your computer and use it in GitHub Desktop.
Save naenumtou/abe1ad2f978d82b4904f19478604e718 to your computer and use it in GitHub Desktop.
#Numpy where and select
s = time.time()
df['where'] = np.where(df['test'] < 50, 1, 0)
e = time.time()
print('where time = {}'.format(e-s))
s = time.time()
df['select'] = np.select([df['test'] < 30, df['test'] < 50], [1,2], default = 3)
e = time.time()
print('Select time = {}'.format(e-s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment