Ravindra BagaleCourses & study guides मराठी Track your progress

10. Dates, Times (IST), and Text

Data Science

10.2 IST Time Zone

# Localise naive timestamps as IST, then optionally convert
df["order_ts"] = df["order_ts"].dt.tz_localize("Asia/Kolkata")
print(df["order_ts"])

df["date"] = df["order_ts"].dt.date
df["hour"] = df["order_ts"].dt.hour
df["month"] = df["order_ts"].dt.month
df["weekday"] = df["order_ts"].dt.day_name()

Worked example. 15-10-2026 19:40 IST is evening Diwali rush in Nashik for Amir’s fictional order — hour 19 helps heatmap later.

Ravindra Bagale's Tip

A date like 01-02-2026 from an Indian export means 1 February, but pandas reads it as 2 January by default. Parse such columns with dayfirst=True, or better, give an exact format="%d-%m-%Y %H:%M". Use tz_localize("Asia/Kolkata") only on times that have no time zone yet; for times that already have one, use tz_convert().