Is your feature request related to a problem?
As a pandas user, I wish I could use pandas to determine which values in a DatetimeIndex are using DST (Daylight Saving Time). This could be useful for a datetime column that recorded values year-round (ex - 1 column with EDT and EST datetimes).
Describe the solution you'd like
- An attribute on DatetimeIndex that is named
is_daylight_savings_time
oris_dst
)
API breaking implications
- None, this is an additive feature
Additional context
- This issue resulted from this discussion:
- https://github.com/pandas-dev/pandas/issues/46998#issuecomment-1135083658
- This attribute could return the following (for each datetime value):
- Value is 0 when DST is not in effect.
- Value is 1 when DST is in effect.
- Value is -1 when DST is unknown.
Comment From: mroeschke
I tried implementing this a few years ago, and it was discouraged https://github.com/pandas-dev/pandas/pull/22560#issuecomment-418707870= so I am not sure it's likely that this will be implemented
Comment From: jreback
idk i think this could be useful (or we add fold instead maybe is better)
Comment From: jbrockmendel
Following #49684, an easy (but non-performant) way to implement this will be folds = np.array([x.fold for x in self], dtype=bool)
. For a more performant implementation we'd need to refactor out parts of ints_to_pydatetime.