NiceMicro on Nostr: #Python magicians of the Fediverse! What is the correct way of converting a datetime ...
#Python magicians of the Fediverse!
What is the correct way of converting a datetime column in #Pandas to my local timezone?
If I do:
```
songlist.head(15)["Time added"].dt.tz_localize("UTC").dt.tz_convert("Asia/Seoul")
```
I have to manually give my location in a string, and for some reason, the `tz_convert` command doesn't recognize "KST" which is what I get from `time.tzname`.
```
datetime.datetime.now().tzinfo
```
returns nothing. What to do?
#Programming #AskFedi
Published at
2024-08-31 23:03:44Event JSON
{
"id": "eee89a3baf33a1762e4e2c9bcde1476d5c710abcaf5138448af4036dae4dd066",
"pubkey": "549be4eccd2d7015f6033c9df13a6ae979ee04572b5c5e059305dedd4740f886",
"created_at": 1725145424,
"kind": 1,
"tags": [
[
"t",
"python"
],
[
"t",
"pandas"
],
[
"t",
"programming"
],
[
"t",
"askfedi"
],
[
"proxy",
"https://fosstodon.org/users/nicemicro/statuses/113059130541909105",
"activitypub"
]
],
"content": "#Python magicians of the Fediverse!\n\nWhat is the correct way of converting a datetime column in #Pandas to my local timezone?\n\nIf I do:\n```\nsonglist.head(15)[\"Time added\"].dt.tz_localize(\"UTC\").dt.tz_convert(\"Asia/Seoul\")\n```\nI have to manually give my location in a string, and for some reason, the `tz_convert` command doesn't recognize \"KST\" which is what I get from `time.tzname`.\n\n```\ndatetime.datetime.now().tzinfo\n```\nreturns nothing. What to do?\n\n#Programming #AskFedi",
"sig": "5da4aa0c738de4b439e6f489c50abb7fdbc428ce13f060a01617ae4d56eb0e9ea60be3de417da78caa85b6e618c13529236384d06e99a7f897c9d5092b4f6347"
}