Created
September 21, 2019 12:59
-
-
Save straussmaximilian/ad7e436eae64a274b598a33bd6204f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pandas | |
import pandas as pd | |
df = pd.DataFrame({'x': array[:, 0], 'y': array[:, 1], 'z': array[:, 2]}) | |
# Pandas query | |
print('Pandas Query:\t\t', end='') | |
%timeit df.query('x >= 0.2 and x <= 0.4 and y >= 0.4 and y <= 0.6') | |
# Pandas eval | |
print('Pandas Eval:\t\t', end='') | |
%timeit df.eval('x >= 0.2 and x <= 0.4 and y >= 0.4 and y <= 0.6') | |
# Boolean index | |
print('Pandas Boolean index:\t', end='') | |
%timeit df[(df['x'] >= 0.2) & (df['y'] >= 0.4) & (df['x'] <= 0.4) & (df['y'] <= 0.6)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment