-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_csv.py
More file actions
27 lines (22 loc) · 864 Bytes
/
Copy pathdebug_csv.py
File metadata and controls
27 lines (22 loc) · 864 Bytes
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
import pandas as pd
import os
# Check the CSV file
csv_path = 'data/Consumer_Complaints_train.csv'
print(f"Checking CSV file: {csv_path}")
print(f"File exists: {os.path.exists(csv_path)}")
# Load the CSV
df = pd.read_csv(csv_path)
print(f"Columns: {df.columns.tolist()}")
print(f"Shape: {df.shape}")
print("Data:")
print(df.to_string())
# Check for empty narratives
print("\nChecking for empty narratives:")
print(f"Rows with empty narrative: {df['Consumer complaint narrative'].isna().sum()}")
print(f"Rows with empty string narrative: {(df['Consumer complaint narrative'] == '').sum()}")
# Check narrative lengths
print("\nNarrative lengths:")
print(df['Consumer complaint narrative'].str.len())
# Check if narratives are longer than 50 characters
print("\nNarratives longer than 50 chars:")
print((df['Consumer complaint narrative'].str.len() > 50).sum())