How does Pandas store timezone information?

Timestamp columns are stored internally in UTC, regardless of whether they have a timezone or not. This is stated in the docs: https://pandas.pydata.org/docs/user_guide/timeseries.html#working-with-time-zones

So how is timezone information stored internally? There must be some sort of tag which makes that column contain pd.Timestamp entries with tz=America/New_York or whatever the timezone is.

Context: I am writing data to disk in a way that is not specific to Python, e.g I am not using pickle. When I retrieve the data I want the timezone information to remain.

Topic pandas python

Category Data Science


I do not know what Pandas uses to store timezone internally, but possibly something like datetime.tzinfo.

On how to represent timezone info cross-platform, the most straight-forward way I can think of is to write the timestamp out as string, using particular format code for the timezone, e.g. %z from here. When another system reads the string, it can parse the timestamp+timezone into the system's own representation.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.