def filter_target_nodes(df):
"""
⚙️ [디버깅 강화판] 노드 정규식 필터 및 실물 데이터 판독 레이어
"""
node_pattern = NODE_PREFIX_PATTERN
print(f"\n🔍 [디버깅 1] config.py에서 로드된 정규식 패턴: '{node_pattern}'")
unique_nodes = df["node"].unique()
print(f"🔍 [디버깅 2] 현재 데이터에 존재하는 고유 노드 목록 (상위 10개):")
for idx, n in enumerate(unique_nodes[:10], 1):
print(f" {idx}. {n}")
print(f" (총 {len(unique_nodes)}개의 고유 노드가 존재함)")
try:
re.compile(node_pattern)
except re.error:
print(f"🚨 [경고] 정규식 문법 오류로 인해 필터가 해제되었습니다.")
node_pattern = ".*"
initial_rows = len(df)
df_filtered = df[df["node"].str.contains(node_pattern, regex=True, na=False, case=False)].reset_index(drop=True)
filtered_rows = len(df_filtered)
dropped_rows = initial_rows - filtered_rows
print(f"📊 [디버깅 3] 필터 결과: {initial_rows:,}행 중 {dropped_rows:,}행 제거 -> {filtered_rows:,}행 생존\n")
return df_filtered