Ravindra BagaleCourses & study guides

10. Dates, Times (IST), and Text

10.1 Parsing dd-mm-yyyy

import pandas as pd

df = pd.DataFrame({
    "order_id": ["BLK-1", "BLK-2", "AMN-3"],
    "order_ts": ["14-03-2026 21:15", "15-10-2026 19:40", "02-09-2026 18:05"],
    "store_code": ["PUN-Kothrud-01", "NSK-College Road-01", "NGP-Sitabuldi-02"],
    "customer": ["Ruhi Bagale", "Amir", "Salman"],
})

df["order_ts"] = pd.to_datetime(df["order_ts"], dayfirst=True)
df

Why dayfirst=True? So 14-03-2026 is 14 March, not invalid / US-style misread.