I'm working with dates in Pandas, the data is saved as UTC in a MongoDB Database.
I'd like to convert it to localtime , this is what I try and it works but the problem is when I want to change the timezone in several columns of my Dataframe :
dfquestions=dfquestions.set_index('date_created')
dfquestions=dfquestions.tz_localize('UTC')
dfquestions=dfquestions.tz_convert('America/Argentina/Buenos_Aires')
If I try to do the same with another column I lose the indexed column.
Example:
dfquestions=dfquestions.set_index('date_created')
dfquestions=dfquestions.tz_localize('UTC')
dfquestions=dfquestions.tz_convert('America/Argentina/Buenos_Aires')
dfquestions=dfquestions.set_index('answer_date_created')
dfquestions=dfquestions.tz_localize('UTC')
dfquestions=dfquestions.tz_convert('America/Argentina/Buenos_Aires')
And I really don't think this is the best way to do it.
所有评论(0)