Localize the Timestamp to a timezone.
Convert naive Timestamp to local time zone or remove timezone from timezone-aware Timestamp.
Time zone for time which Timestamp will be converted to. None will remove timezone holding local time.
When clocks moved backward due to DST, ambiguous times may arise. For example in Central European Time (UTC+01), when going from 03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at 00:30:00 UTC and at 01:30:00 UTC. In such a situation, the ambiguous parameter dictates how ambiguous times should be handled.
The behavior is as follows:
bool contains flags to determine if time is dst or not (note that this flag is only applicable for ambiguous fall dst dates).
âNaTâ will return NaT for an ambiguous time.
âraiseâ will raise an AmbiguousTimeError for an ambiguous time.
A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.
The behavior is as follows:
âshift_forwardâ will shift the nonexistent time forward to the closest existing time.
âshift_backwardâ will shift the nonexistent time backward to the closest existing time.
âNaTâ will return NaT where there are nonexistent times.
timedelta objects will shift nonexistent times by the timedelta.
âraiseâ will raise an NonExistentTimeError if there are nonexistent times.
If the Timestamp is tz-aware and tz is not None.
Examples
Create a naive timestamp object:
>>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts Timestamp('2020-03-14 15:32:52.192548651')
Add âEurope/Stockholmâ as timezone:
>>> ts.tz_localize(tz='Europe/Stockholm') Timestamp('2020-03-14 15:32:52.192548651+0100', tz='Europe/Stockholm')
Analogous for pd.NaT
:
>>> pd.NaT.tz_localize() NaT
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4