A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/docs/reference/api/pandas.DatetimeIndex.as_unit.html below:

pandas.DatetimeIndex.as_unit — pandas 2.3.1 documentation

pandas.DatetimeIndex.as_unit#
DatetimeIndex.as_unit(*args, **kwargs)[source]#

Convert to a dtype with the given unit resolution.

Parameters:
unit{‘s’, ‘ms’, ‘us’, ‘ns’}
Returns:
same type as self

Examples

For pandas.DatetimeIndex:

>>> idx = pd.DatetimeIndex(['2020-01-02 01:02:03.004005006'])
>>> idx
DatetimeIndex(['2020-01-02 01:02:03.004005006'],
              dtype='datetime64[ns]', freq=None)
>>> idx.as_unit('s')
DatetimeIndex(['2020-01-02 01:02:03'], dtype='datetime64[s]', freq=None)

For pandas.TimedeltaIndex:

>>> tdelta_idx = pd.to_timedelta(['1 day 3 min 2 us 42 ns'])
>>> tdelta_idx
TimedeltaIndex(['1 days 00:03:00.000002042'],
                dtype='timedelta64[ns]', freq=None)
>>> tdelta_idx.as_unit('s')
TimedeltaIndex(['1 days 00:03:00'], dtype='timedelta64[s]', freq=None)

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