Daveabc12 commited on
Commit
265a83e
·
verified ·
1 Parent(s): e845a6b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -392,10 +392,9 @@ def load_all_data(folder_path):
392
  # 1. Read CSV without parsing dates yet (load as strings to be safe)
393
  df = pd.read_csv(file_path, header=0, index_col=0, encoding='utf-8')
394
 
395
- # 2. ROBUST DATE PARSING (The "Zig-Zag" Fix)
396
- # We explicitly force dayfirst=True here on the index object.
397
- # 'coerce' turns invalid formats into NaT so we can drop them.
398
- df.index = pd.to_datetime(df.index, dayfirst=True, errors='coerce')
399
 
400
  # 3. Drop rows with invalid dates
401
  df = df[df.index.notna()]
 
392
  # 1. Read CSV without parsing dates yet (load as strings to be safe)
393
  df = pd.read_csv(file_path, header=0, index_col=0, encoding='utf-8')
394
 
395
+ # 2. FORCE ISO PARSING (YYYY-MM-DD)
396
+ # We disable 'dayfirst' because ISO puts Year first.
397
+ df.index = pd.to_datetime(df.index, format='%Y-%m-%d', errors='coerce')
 
398
 
399
  # 3. Drop rows with invalid dates
400
  df = df[df.index.notna()]