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
In previous versions of pandas, resampling a ``Series``/``DataFrame`` indexed by a ``PeriodIndex`` returned a ``DatetimeIndex`` in some cases (:issue:`12884`). Resampling to a multiplied frequency now returns a ``PeriodIndex`` (:issue:`15944`).
179
+
180
+
Previous Behavior:
181
+
182
+
.. code-block:: ipython
183
+
184
+
In [1]: pi = pd.period_range('2017-01', periods=12, freq='M')
pi = pd.period_range('2017-01', periods=12, freq='M')
205
+
206
+
s = pd.Series(np.arange(12), index=pi)
207
+
208
+
resampled = s.resample('2Q').mean()
209
+
210
+
resampled
211
+
212
+
resampled.index
213
+
214
+
215
+
Upsampling and calling ``.ohlc()`` previously returned a ``Series``, basically identical to calling ``.asfreq()``. OHLC upsampling now returns a DataFrame with columns ``open``, ``high``, ``low`` and ``close`` (:issue:`13083`). This is consistent with downsampling and ``DatetimeIndex`` behavior.
216
+
217
+
Previous Behavior:
218
+
219
+
.. code-block:: ipython
220
+
221
+
In [1]: pi = pd.PeriodIndex(start='2000-01-01', freq='D', periods=10)
222
+
223
+
In [2]: s = pd.Series(np.arange(10), index=pi)
224
+
225
+
In [3]: s.resample('H').ohlc()
226
+
Out[3]:
227
+
2000-01-01 00:00 0.0
228
+
...
229
+
2000-01-10 23:00 NaN
230
+
Freq: H, Length: 240, dtype: float64
231
+
232
+
In [4]: s.resample('M').ohlc()
233
+
Out[4]:
234
+
open high low close
235
+
2000-01 0 9 0 9
236
+
237
+
New Behavior:
238
+
239
+
.. ipython:: python
240
+
241
+
pi = pd.PeriodIndex(start='2000-01-01', freq='D', periods=10)
242
+
243
+
s = pd.Series(np.arange(10), index=pi)
244
+
245
+
s.resample('H').ohlc()
246
+
247
+
s.resample('M').ohlc()
248
+
249
+
250
+
As a minor enhancement, resampling a ``PeriodIndex`` can now handle ``NaT`` values (:issue:`13224`)
0 commit comments