-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_data.py
More file actions
45 lines (35 loc) · 1.38 KB
/
Copy pathtest_data.py
File metadata and controls
45 lines (35 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"""
Test script to verify CSV data loading
"""
import sys
import os
# Add backend to path
backend_dir = os.path.join(os.path.dirname(__file__), 'backend')
sys.path.insert(0, backend_dir)
def test_data_loading():
try:
from services.data_loader import load_dataset, ensure_loaded
from core.config import settings
print("🔍 Testing data loading...")
print(f"📁 Data path: {settings.DATA_PATH}")
# Load the dataset
df = ensure_loaded()
print(f"✅ Successfully loaded {len(df):,} rows")
print(f"📊 Columns: {list(df.columns)}")
if len(df) > 0:
print(f"📅 Date range: {df['date'].min()} to {df['date'].max()}")
print(f"🗺️ Coordinate range:")
print(f" Latitude: {df['lat'].min():.4f} to {df['lat'].max():.4f}")
print(f" Longitude: {df['lng'].min():.4f} to {df['lng'].max():.4f}")
print(f"🚨 Crime types: {df['crime_type'].unique()[:5]}")
print("\n📋 Sample data:")
print(df[['lat', 'lng', 'crime_type', 'date']].head(3).to_string())
return True
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
test_data_loading()