Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"TypeError: Already tz-aware, use tz_convert to convert." when I update pandas

I have update pandas from 0.20 to 0.21.1 (anaconda distribution) and I have an message error: "TypeError: Already tz-aware, use tz_convert to convert." when I executed this code with python 0.20 it worked perfectly !!

 PvBrut['Date'] = PvBrut.Date.dt.tz_localize('UTC').dt.tz_convert('Europe/Paris')+timedelta(minutes=5)
like image 301
Stef Reyes Avatar asked Jan 26 '26 15:01

Stef Reyes


1 Answers

Datetime is already localized to a timezone, UTC.

Don't call .tz_localize on it. Just convert it by using .tz_convert('UTC')

like image 179
Prateek Singh Avatar answered Jan 29 '26 12:01

Prateek Singh