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

post/count_consecutive_zeros/ #20

Open
utterances-bot opened this issue Aug 17, 2024 · 2 comments
Open

post/count_consecutive_zeros/ #20

utterances-bot opened this issue Aug 17, 2024 · 2 comments

Comments

@utterances-bot
Copy link

Numpy 系列:统计序列里零值连续出现的次数 - 炸鸡人博客

A minimal Hugo theme with nice theme color.

https://zhajiman.github.io/post/count_consecutive_zeros/

Copy link

这里 value_counts = unique_counts[np.searchsorted(unique, value_id)] , 中括号里面的结果就等于 value_id, 所以是不是直接 value_counts = unique_counts[value_id] 就行了?

Copy link
Owner

感谢反馈,你说的对,括号里的结果就是 value_id,直接 value_counts = unique_counts[value_id] 就行。
unique 数组的值是连续的 [0, 1, 2, ..., n - 1],对应 0n - 1n 个 id,那 value_id 的值能直接作为 unique_counts 的索引。

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

No branches or pull requests

3 participants