Created
October 4, 2013 20:36
-
-
Save drasch/6832315 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
df = pd.DataFrame(np.random.randn(10000), index=range(0,10000), columns=['length']) | |
df.index.name = 'id' | |
df2 = pd.DataFrame.from_dict({'selector':randint(0,2, 20000), 'df_index': randint(1,10000,20000)}) | |
# df_index is a foreign key into df.index | |
df['in_selector_0'] = np.asarray(np.where(df.reset_index().id.isin(df2[df2.selector.between(0,0.1)].df_index),'y', 'n')) | |
df.in_selector_0.value_counts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment