Spaces:
Sleeping
Sleeping
Rajan Sharma
commited on
Update data_registry.py
Browse files- 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 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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({
|