Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isin is slow #603

Closed
maartenbreddels opened this issue Feb 18, 2020 · 5 comments · Fixed by #822
Closed

isin is slow #603

maartenbreddels opened this issue Feb 18, 2020 · 5 comments · Fixed by #822

Comments

@maartenbreddels
Copy link
Member

maartenbreddels commented Feb 18, 2020

import numpy as np
import vaex
N = 1_000_000
M = 10
s = np.random.randint(ord('a'), ord('z'), (N, M), np.uint32).view('U10').reshape(N)
s_selection = s[:1000]
df = vaex.from_arrays(s=s)
%%timeit -n3 -r3
df.s.isin(s_selection).count()

Takes 6 seconds! That is way too slow, we should use a hashmap/set here.

@maartenbreddels
Copy link
Member Author

Originally reported by @stephanpcpeters (private via slack)

@joshreback
Copy link

joshreback commented Jun 9, 2020

Hi, I think this may be the cause of my StackOverflow query here: https://stackoverflow.com/questions/62292479/performance-tips-for-using-vaex. Are there any workarounds for this?

@maartenbreddels
Copy link
Member Author

No workaround, work for me :)
Hope to release the performance improvement in #822 very soon.

@maartenbreddels
Copy link
Member Author

Let us know if this solve it
pip install "vaex-core>=2.0.3"

@maartenbreddels
Copy link
Member Author

Note that for optimal performance, one should not pass a numpy arrays with strings, if read from hdf5 or arrow, it's fine, otherwise do sth like:

import pyarrow as pa
df = vaex.from_arrays(s=pa.array(s))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants