[ pandas.TimedeltaIndex.round ](pandas.TimedeltaIndex.round.html)
    * [ pandas.TimedeltaIndex.floor ](pandas.TimedeltaIndex.floor.html)
    * [ pandas.TimedeltaIndex.ceil ](pandas.TimedeltaIndex.ceil.html)
    * [ pandas.TimedeltaIndex.to_frame ](pandas.TimedeltaIndex.to_frame.html)
    * [ pandas.TimedeltaIndex.mean ](pandas.TimedeltaIndex.mean.html)
    * [ pandas.PeriodIndex ](pandas.PeriodIndex.html)
    * [ pandas.PeriodIndex.day ](pandas.PeriodIndex.day.html)
    * [ pandas.PeriodIndex.dayofweek ](pandas.PeriodIndex.dayofweek.html)
    * [ pandas.PeriodIndex.day_of_week ](pandas.PeriodIndex.day_of_week.html)
    * [ pandas.PeriodIndex.dayofyear ](pandas.PeriodIndex.dayofyear.html)
    * [ pandas.PeriodIndex.day_of_year ](pandas.PeriodIndex.day_of_year.html)
    * [ pandas.PeriodIndex.days_in_month ](pandas.PeriodIndex.days_in_month.html)
    * [ pandas.PeriodIndex.daysinmonth ](pandas.PeriodIndex.daysinmonth.html)
    * [ pandas.PeriodIndex.end_time ](pandas.PeriodIndex.end_time.html)
    * [ pandas.PeriodIndex.freq ](pandas.PeriodIndex.freq.html)
    * [ pandas.PeriodIndex.freqstr ](pandas.PeriodIndex.freqstr.html)
    * [ pandas.PeriodIndex.hour ](pandas.PeriodIndex.hour.html)
    * [ pandas.PeriodIndex.is_leap_year ](pandas.PeriodIndex.is_leap_year.html)
    * [ pandas.PeriodIndex.minute ](pandas.PeriodIndex.minute.html)
    * [ pandas.PeriodIndex.month ](pandas.PeriodIndex.month.html)
    * [ pandas.PeriodIndex.quarter ](pandas.PeriodIndex.quarter.html)
    * [ pandas.PeriodIndex.qyear ](pandas.PeriodIndex.qyear.html)
    * [ pandas.PeriodIndex.second ](pandas.PeriodIndex.second.html)
    * [ pandas.PeriodIndex.start_time ](pandas.PeriodIndex.start_time.html)
    * [ pandas.PeriodIndex.week ](pandas.PeriodIndex.week.html)
    * [ pandas.PeriodIndex.weekday ](pandas.PeriodIndex.weekday.html)
    * [ pandas.PeriodIndex.weekofyear ](pandas.PeriodIndex.weekofyear.html)
    * [ pandas.PeriodIndex.year ](pandas.PeriodIndex.year.html)
    * [ pandas.PeriodIndex.asfreq ](pandas.PeriodIndex.asfreq.html)
    * [ pandas.PeriodIndex.strftime ](pandas.PeriodIndex.strftime.html)
    * [ pandas.PeriodIndex.to_timestamp ](pandas.PeriodIndex.to_timestamp.html)
    * [ pandas.PeriodIndex.from_fields ](pandas.PeriodIndex.from_fields.html)
    * [ pandas.PeriodIndex.from_ordinals ](pandas.PeriodIndex.from_ordinals.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * __
  * [ pandas.DatetimeIndex ](pandas.DatetimeIndex.html)
  * pandas.Datet... 

#  pandas.DatetimeIndex.snap  #

DatetimeIndex.  snap  (  _ freq  =  'S'  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/indexes/datetimes.py#L481-L516) #

    

Snap time stamps to nearest occurring frequency.

Returns  :

    

DatetimeIndex

    

Examples

    
    
    >>> idx = pd.DatetimeIndex(['2023-01-01', '2023-01-02',
    ...                        '2023-02-01', '2023-02-02'])
    >>> idx
    DatetimeIndex(['2023-01-01', '2023-01-02', '2023-02-01', '2023-02-02'],
    dtype='datetime64[ns]', freq=None)
    >>> idx.snap('MS')
    DatetimeIndex(['2023-01-01', '2023-01-01', '2023-02-01', '2023-02-01'],
    dtype='datetime64[ns]', freq=None)
    

[ __ previous  pandas.DatetimeIndex.strftime
](pandas.DatetimeIndex.strftime.html "previous page") [ next
pandas.DatetimeIndex.tz_convert  __ ](pandas.DatetimeIndex.tz_convert.html
"next page")

__ On this page

  * ` DatetimeIndex.snap()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DatetimeIndex.snap.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://ww