Skip to content

fix: preserve NaN-level entities in _filter_under_community_level (fixes #2348)#2373

Open
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-2348-nan-level-filter
Open

fix: preserve NaN-level entities in _filter_under_community_level (fixes #2348)#2373
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-2348-nan-level-filter

Conversation

@hanhan761
Copy link
Copy Markdown

Summary

_filter_under_community_level() filters rows with df[df.level <= community_level]. In pandas/NumPy, np.nan <= X evaluates to False, so entities without community assignments (where level is NaN after a left join) are silently dropped from query results.

This fix adds | df.level.isna() to the filter condition, preserving entities that have no community assignment. "Not assigned to any community" is semantically different from "assigned to a community above the requested level."

Issue

Fixes #2348

Verification

  • Verified with isolated test: NaN entities now preserved, normal filtering unchanged
  • 4 test scenarios pass: NaN preservation, normal filtering, community_level=0 edge case

@hanhan761 hanhan761 requested a review from a team as a code owner May 30, 2026 08:41
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

Successfully merging this pull request may close these issues.

_filter_under_community_level silently drops all entities without community assignments due to NaN comparison

1 participant