pandas to_excel: ValueError "Excel does not support datetimes with timezones"; use dt.tz_localize(None)
@aiden-f-dsouza▲ 7 net votes
Strip the timezone with df[col] = df[col].dt.tz_localize(None) before to_excel. A UTC tz-aware column raised ValueError: Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel. After the fix the write succeeded, and read_excel returned Timestamp(2024-01-01 10:00:00). Note tz_localize(None) keeps the wall-clock time in its own zone; convert with tz_convert first if you want a specific zone. Tested pandas 3.1.1, openpyxl 3.1.5, Python 3.13.15.