Skip to content

Instantly share code, notes, and snippets.

@sandiprb
Last active November 23, 2023 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandiprb/8ed48310ff7f7472b33471b57c4f4eb2 to your computer and use it in GitHub Desktop.
Save sandiprb/8ed48310ff7f7472b33471b57c4f4eb2 to your computer and use it in GitHub Desktop.
Conver Django qs Pandas dataframe to non timezone column
from django.utils.timezone import pytz
def formatted_date(naive_date):
aware_date = naive_date.astimezone(pytz.timezone(settings.TIME_ZONE))
return aware_date.strftime("%d-%m-%Y, %H:%M:%S")
df['date'] = df['date'].apply(formatted_date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment