ENH: add option to tz_localize to return NaT instead of raising a NonExistentTimeError (original) (raw)
It would be nice if the tz_localize function of a DatetimeIndex had an optional flag for silently returning NaT instead of throwing a NonExistentTimeError, if the timestamp is not valid in the given timezone (for example due to DST changes).
I ran into this problem while trying to tz_localize a large index, and it seems to me that this would be a much better solution than manually handling the exception with a lambda expression in a (slow) python loop.