@@ -28,7 +28,7 @@ Generate sequences of fixed-frequency dates and time spans
28
28
29
29
.. ipython :: python
30
30
31
- dti = pd.date_range(" 2018-01-01" , periods = 3 , freq = " H " )
31
+ dti = pd.date_range(" 2018-01-01" , periods = 3 , freq = " h " )
32
32
dti
33
33
34
34
Manipulating and converting date times with timezone information
@@ -43,10 +43,10 @@ Resampling or converting a time series to a particular frequency
43
43
44
44
.. ipython :: python
45
45
46
- idx = pd.date_range(" 2018-01-01" , periods = 5 , freq = " H " )
46
+ idx = pd.date_range(" 2018-01-01" , periods = 5 , freq = " h " )
47
47
ts = pd.Series(range (len (idx)), index = idx)
48
48
ts
49
- ts.resample(" 2H " ).mean()
49
+ ts.resample(" 2h " ).mean()
50
50
51
51
Performing date and time arithmetic with absolute or relative time increments
52
52
@@ -641,7 +641,7 @@ We are stopping on the included end-point as it is part of the index:
641
641
np.random.randn(20 , 1 ),
642
642
columns = [" A" ],
643
643
index = pd.MultiIndex.from_product(
644
- [pd.date_range(" 20130101" , periods = 10 , freq = " 12H " ), [" a" , " b" ]]
644
+ [pd.date_range(" 20130101" , periods = 10 , freq = " 12h " ), [" a" , " b" ]]
645
645
),
646
646
)
647
647
dft2
@@ -901,10 +901,10 @@ into ``freq`` keyword arguments. The available date offsets and associated frequ
901
901
:class: `~pandas.tseries.offsets.BYearBegin `, ``'BAS' ``, "business year begin"
902
902
:class: `~pandas.tseries.offsets.FY5253 `, ``'RE' ``, "retail (aka 52-53 week) year"
903
903
:class: `~pandas.tseries.offsets.Easter `, None, "Easter holiday"
904
- :class: `~pandas.tseries.offsets.BusinessHour `, ``'BH ' ``, "business hour"
905
- :class: `~pandas.tseries.offsets.CustomBusinessHour `, ``'CBH ' ``, "custom business hour"
904
+ :class: `~pandas.tseries.offsets.BusinessHour `, ``'bh ' ``, "business hour"
905
+ :class: `~pandas.tseries.offsets.CustomBusinessHour `, ``'cbh ' ``, "custom business hour"
906
906
:class: `~pandas.tseries.offsets.Day `, ``'D' ``, "one absolute day"
907
- :class: `~pandas.tseries.offsets.Hour `, ``'H ' ``, "one hour"
907
+ :class: `~pandas.tseries.offsets.Hour `, ``'h ' ``, "one hour"
908
908
:class: `~pandas.tseries.offsets.Minute `, ``'min' ``,"one minute"
909
909
:class: `~pandas.tseries.offsets.Second `, ``'s' ``, "one second"
910
910
:class: `~pandas.tseries.offsets.Milli `, ``'ms' ``, "one millisecond"
@@ -1262,8 +1262,9 @@ frequencies. We will refer to these aliases as *offset aliases*.
1262
1262
"BA, BY", "business year end frequency"
1263
1263
"AS, YS", "year start frequency"
1264
1264
"BAS, BYS", "business year start frequency"
1265
- "BH", "business hour frequency"
1266
- "H", "hourly frequency"
1265
+ "h", "hourly frequency"
1266
+ "bh", "business hour frequency"
1267
+ "cbh", "custom business hour frequency"
1267
1268
"min", "minutely frequency"
1268
1269
"s", "secondly frequency"
1269
1270
"ms", "milliseconds"
@@ -1272,7 +1273,8 @@ frequencies. We will refer to these aliases as *offset aliases*.
1272
1273
1273
1274
.. deprecated :: 2.2.0
1274
1275
1275
- Aliases ``T ``, ``S ``, ``L ``, ``U ``, and ``N `` are deprecated in favour of the aliases
1276
+ Aliases ``H ``, ``BH ``, ``CBH ``, ``T ``, ``S ``, ``L ``, ``U ``, and ``N ``
1277
+ are deprecated in favour of the aliases ``h ``, ``bh ``, ``cbh ``,
1276
1278
``min ``, ``s ``, ``ms ``, ``us ``, and ``ns ``.
1277
1279
1278
1280
.. note ::
@@ -1322,7 +1324,7 @@ frequencies. We will refer to these aliases as *period aliases*.
1322
1324
"M", "monthly frequency"
1323
1325
"Q", "quarterly frequency"
1324
1326
"Y", "yearly frequency"
1325
- "H ", "hourly frequency"
1327
+ "h ", "hourly frequency"
1326
1328
"min", "minutely frequency"
1327
1329
"s", "secondly frequency"
1328
1330
"ms", "milliseconds"
@@ -1331,8 +1333,8 @@ frequencies. We will refer to these aliases as *period aliases*.
1331
1333
1332
1334
.. deprecated :: 2.2.0
1333
1335
1334
- Aliases ``A ``, ``T ``, ``S ``, ``L ``, ``U ``, and ``N `` are deprecated in favour of the aliases
1335
- ``Y ``, ``min ``, ``s ``, ``ms ``, ``us ``, and ``ns ``.
1336
+ Aliases ``A ``, ``H ``, `` T ``, ``S ``, ``L ``, ``U ``, and ``N `` are deprecated in favour of the aliases
1337
+ ``Y ``, ``h ``, `` min ``, ``s ``, ``ms ``, ``us ``, and ``ns ``.
1336
1338
1337
1339
1338
1340
Combining aliases
@@ -1889,7 +1891,7 @@ natural and functions similarly to :py:func:`itertools.groupby`:
1889
1891
]
1890
1892
),
1891
1893
)
1892
- resampled = small.resample(" H " )
1894
+ resampled = small.resample(" h " )
1893
1895
1894
1896
for name, group in resampled:
1895
1897
print (" Group: " , name)
@@ -1999,9 +2001,9 @@ Because ``freq`` represents a span of ``Period``, it cannot be negative like "-3
1999
2001
2000
2002
pd.Period(" 2012-1-1" , freq = " D" )
2001
2003
2002
- pd.Period(" 2012-1-1 19:00" , freq = " H " )
2004
+ pd.Period(" 2012-1-1 19:00" , freq = " h " )
2003
2005
2004
- pd.Period(" 2012-1-1 19:00" , freq = " 5H " )
2006
+ pd.Period(" 2012-1-1 19:00" , freq = " 5h " )
2005
2007
2006
2008
Adding and subtracting integers from periods shifts the period by its own
2007
2009
frequency. Arithmetic is not allowed between ``Period `` with different ``freq `` (span).
@@ -2021,7 +2023,7 @@ If ``Period`` freq is daily or higher (``D``, ``H``, ``T``, ``S``, ``L``, ``U``,
2021
2023
2022
2024
.. ipython :: python
2023
2025
2024
- p = pd.Period(" 2014-07-01 09:00" , freq = " H " )
2026
+ p = pd.Period(" 2014-07-01 09:00" , freq = " h " )
2025
2027
p + pd.offsets.Hour(2 )
2026
2028
p + datetime.timedelta(minutes = 120 )
2027
2029
p + np.timedelta64(7200 , " s" )
@@ -2097,7 +2099,7 @@ objects:
2097
2099
2098
2100
.. ipython :: python
2099
2101
2100
- idx = pd.period_range(" 2014-07-01 09:00" , periods = 5 , freq = " H " )
2102
+ idx = pd.period_range(" 2014-07-01 09:00" , periods = 5 , freq = " h " )
2101
2103
idx
2102
2104
idx + pd.offsets.Hour(2 )
2103
2105
@@ -2168,13 +2170,13 @@ Passing a string representing a lower frequency than ``PeriodIndex`` returns par
2168
2170
index = pd.period_range(" 2013-01-01 9:00" , periods = 600 , freq = " min" ),
2169
2171
)
2170
2172
dfp
2171
- dfp.loc[" 2013-01-01 10H " ]
2173
+ dfp.loc[" 2013-01-01 10h " ]
2172
2174
2173
2175
As with ``DatetimeIndex ``, the endpoints will be included in the result. The example below slices data starting from 10:00 to 11:59.
2174
2176
2175
2177
.. ipython :: python
2176
2178
2177
- dfp[" 2013-01-01 10H " :" 2013-01-01 11H " ]
2179
+ dfp[" 2013-01-01 10h " :" 2013-01-01 11h " ]
2178
2180
2179
2181
2180
2182
Frequency conversion and resampling with PeriodIndex
@@ -2286,7 +2288,7 @@ the quarter end:
2286
2288
2287
2289
ts = pd.Series(np.random.randn(len (prng)), prng)
2288
2290
2289
- ts.index = (prng.asfreq(" M" , " e" ) + 1 ).asfreq(" H " , " s" ) + 9
2291
+ ts.index = (prng.asfreq(" M" , " e" ) + 1 ).asfreq(" h " , " s" ) + 9
2290
2292
2291
2293
ts.head()
2292
2294
@@ -2505,7 +2507,7 @@ To remove time zone information, use ``tz_localize(None)`` or ``tz_convert(None)
2505
2507
2506
2508
.. ipython :: python
2507
2509
2508
- didx = pd.date_range(start = " 2014-08-01 09:00" , freq = " H " , periods = 3 , tz = " US/Eastern" )
2510
+ didx = pd.date_range(start = " 2014-08-01 09:00" , freq = " h " , periods = 3 , tz = " US/Eastern" )
2509
2511
didx
2510
2512
didx.tz_localize(None )
2511
2513
didx.tz_convert(None )
@@ -2602,7 +2604,7 @@ can be controlled by the ``nonexistent`` argument. The following options are ava
2602
2604
2603
2605
.. ipython :: python
2604
2606
2605
- dti = pd.date_range(start = " 2015-03-29 02:30:00" , periods = 3 , freq = " H " )
2607
+ dti = pd.date_range(start = " 2015-03-29 02:30:00" , periods = 3 , freq = " h " )
2606
2608
# 2:30 is a nonexistent time
2607
2609
2608
2610
Localization of nonexistent times will raise an error by default.
@@ -2619,7 +2621,7 @@ Transform nonexistent times to ``NaT`` or shift the times.
2619
2621
dti
2620
2622
dti.tz_localize(" Europe/Warsaw" , nonexistent = " shift_forward" )
2621
2623
dti.tz_localize(" Europe/Warsaw" , nonexistent = " shift_backward" )
2622
- dti.tz_localize(" Europe/Warsaw" , nonexistent = pd.Timedelta(1 , unit = " H " ))
2624
+ dti.tz_localize(" Europe/Warsaw" , nonexistent = pd.Timedelta(1 , unit = " h " ))
2623
2625
dti.tz_localize(" Europe/Warsaw" , nonexistent = " NaT" )
2624
2626
2625
2627
0 commit comments