You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/timeseries.rst
+22-5
Original file line number
Diff line number
Diff line change
@@ -591,7 +591,7 @@ various docstrings for the classes.
591
591
These operations (``apply``, ``rollforward`` and ``rollback``) preserves time (hour, minute, etc) information by default. To reset time, use ``normalize=True`` keyword when creating the offset instance. If ``normalize=True``, result is normalized after the function is applied.
592
592
593
593
594
-
.. ipython:: python
594
+
.. ipython:: python
595
595
596
596
day = Day()
597
597
day.apply(Timestamp('2014-01-01 09:00'))
@@ -1257,8 +1257,10 @@ be created with the convenience function ``period_range``.
1257
1257
1258
1258
Period
1259
1259
~~~~~~
1260
+
1260
1261
A ``Period`` represents a span of time (e.g., a day, a month, a quarter, etc).
1261
-
It can be created using a frequency alias:
1262
+
You can specify the span via ``freq`` keyword using a frequency alias like below.
1263
+
Because ``freq`` represents a span of ``Period``, it cannot be negative like "-3D".
1262
1264
1263
1265
.. ipython:: python
1264
1266
@@ -1268,11 +1270,10 @@ It can be created using a frequency alias:
1268
1270
1269
1271
Period('2012-1-1 19:00', freq='H')
1270
1272
1271
-
Unlike time stamped data, pandas does not support frequencies at multiples of
1272
-
DateOffsets (e.g., '3Min') for periods.
1273
+
Period('2012-1-1 19:00', freq='5H')
1273
1274
1274
1275
Adding and subtracting integers from periods shifts the period by its own
1275
-
frequency.
1276
+
frequency. Arithmetic is not allowed between ``Period`` with different ``freq`` (span).
1276
1277
1277
1278
.. ipython:: python
1278
1279
@@ -1282,6 +1283,15 @@ frequency.
1282
1283
1283
1284
p -3
1284
1285
1286
+
p = Period('2012-01', freq='2M')
1287
+
1288
+
p +2
1289
+
1290
+
p -1
1291
+
1292
+
p == Period('2012-01', freq='3M')
1293
+
1294
+
1285
1295
If ``Period`` freq is daily or higher (``D``, ``H``, ``T``, ``S``, ``L``, ``U``, ``N``), ``offsets`` and ``timedelta``-like can be added if the result can have the same freq. Otherise, ``ValueError`` will be raised.
1286
1296
1287
1297
.. ipython:: python
@@ -1335,6 +1345,13 @@ The ``PeriodIndex`` constructor can also be used directly:
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.17.0.txt
+26-1
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,32 @@ We are now supporting a ``Series.dt.strftime`` method for datetime-likes to gene
120
120
121
121
The string format is as the python standard library and details can be found `here <https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior>`_
122
122
123
+
.. _whatsnew_0170.periodfreq:
124
+
125
+
Period Frequency Enhancement
126
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
+
128
+
``Period``, ``PeriodIndex`` and ``period_range`` can now accept multiplied freq. Also, ``Period.freq`` and ``PeriodIndex.freq`` are now stored as ``DateOffset`` instance like ``DatetimeIndex``, not ``str`` (:issue:`7811`)
129
+
130
+
Multiplied freq represents a span of corresponding length. Below example creates a period of 3 days. Addition and subtraction will shift the period by its span.
131
+
132
+
.. ipython:: python
133
+
134
+
p = pd.Period('2015-08-01', freq='3D')
135
+
p
136
+
p + 1
137
+
p - 2
138
+
p.to_timestamp()
139
+
p.to_timestamp(how='E')
140
+
141
+
You can use multiplied freq in ``PeriodIndex`` and ``period_range``.
- ``pd.Timedelta.total_seconds()`` now returns Timedelta duration to ns precision (previously microsecond precision) (:issue: `10939`)
199
225
200
226
- ``.as_blocks`` will now take a ``copy`` optional argument to return a copy of the data, default is to copy (no change in behavior from prior versions), (:issue:`9607`)
201
-
202
227
- ``regex`` argument to ``DataFrame.filter`` now handles numeric column names instead of raising ``ValueError`` (:issue:`10384`).
203
228
- ``pd.read_stata`` will now read Stata 118 type files. (:issue:`9882`)
0 commit comments