Can I use my helper function to determine if a shot was a three pointer as a filter function in Pandas? My actual function is much more complex, but i simplified it for this question.
def isThree(x, y):return (x + y == 3)print data[isThree(data['x'], data['y'])].head()
Yes:
import numpy as np
import pandas as pddata = pd.DataFrame({'x': np.random.randint(1,3,10),'y': np.random.randint(1,3,10)})
print(data)
Output:
x y
0 1 2
1 2 1
2 2 1
3 1 2
4 2 1
5 2 1
6 2 1
7 2 1
8 2 1
9 2 2
def isThree(x, y):return (x + y == 3)print(data[isThree(data['x'], data['y'])].head())
Output:
x y
0 1 2
1 2 1
2 2 1
3 1 2
4 2 1