Rajan Sharma commited on
Commit
6c051db
·
verified ·
1 Parent(s): c01c57e

Update data_registry.py

Browse files
Files changed (1) hide show
  1. data_registry.py +14 -3
data_registry.py CHANGED
@@ -83,9 +83,20 @@ class DataRegistry:
83
  # Check data content
84
  data_matches = False
85
  for col in df.select_dtypes(include=['object']).columns:
86
- if any(df[col].str.contains('|'.join(keywords), case=False, na=False).any()):
87
- data_matches = True
88
- break
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  if col_matches or data_matches:
91
  related.append({
 
83
  # Check data content
84
  data_matches = False
85
  for col in df.select_dtypes(include=['object']).columns:
86
+ try:
87
+ # Create a boolean mask for rows containing any keyword
88
+ # This is the generic approach that works for any keywords
89
+ pattern = '|'.join(keywords)
90
+ mask = df[col].str.contains(pattern, case=False, na=False)
91
+
92
+ # Check if any match exists (this returns a single boolean)
93
+ if mask.any():
94
+ data_matches = True
95
+ break
96
+ except Exception as e:
97
+ # If there's an error with this column, skip it
98
+ logger.debug(f"Error checking column {col} for keywords: {str(e)}")
99
+ continue
100
 
101
  if col_matches or data_matches:
102
  related.append({