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`). As a minor enhancement, resampling a ``PeriodIndex`` can now handle ``NaT`` values (:issue:`13224`)
180
+
181
+
Previous Behavior:
182
+
183
+
.. code-block:: ipython
184
+
185
+
In [1]: pi = pd.period_range('2017-01', periods=12, freq='M')
pi = pd.period_range('2017-01', periods=12, freq='M')
206
+
207
+
s = pd.Series(np.arange(12), index=pi)
208
+
209
+
resampled = s.resample('2Q').mean()
210
+
211
+
resampled
212
+
213
+
resampled.index
214
+
215
+
216
+
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.
217
+
218
+
Previous Behavior:
219
+
220
+
.. code-block:: ipython
221
+
222
+
In [1]: pi = pd.PeriodIndex(start='2000-01-01', freq='D', periods=10)
223
+
224
+
In [2]: s = pd.Series(np.arange(10), index=pi)
225
+
226
+
In [3]: s.resample('H').ohlc()
227
+
Out[3]:
228
+
2000-01-01 00:00 0.0
229
+
...
230
+
2000-01-10 23:00 NaN
231
+
Freq: H, Length: 240, dtype: float64
232
+
233
+
In [4]: s.resample('M').ohlc()
234
+
Out[4]:
235
+
open high low close
236
+
2000-01 0 9 0 9
237
+
238
+
New Behavior:
239
+
240
+
.. ipython:: python
241
+
242
+
pi = pd.PeriodIndex(start='2000-01-01', freq='D', periods=10)
0 commit comments