pandas.api.typing.Resampler.ohlc#
- final Resampler.ohlc(numeric_only=False)[source]#
Compute open, high, low and close values of a group, excluding missing values.
This method computes OHLC (Open-High-Low-Close) values, commonly used in financial data analysis to summarize price movements within time periods.
- Parameters:
- numeric_onlybool, default False
Include only float, int, boolean columns.
Added in version 3.2.0.
- Returns:
- DataFrame
Open, high, low and close values within each group.
See also
DataFrame.aggAggregate using one or more operations over the specified axis.
DataFrame.resampleResample time-series data.
DataFrame.groupbyGroup DataFrame using a mapper or by a Series of columns.
Examples
>>> ser = pd.Series( ... [1, 3, 2, 4, 3, 5], ... index=pd.DatetimeIndex( ... [ ... "2023-01-01", ... "2023-01-10", ... "2023-01-15", ... "2023-02-01", ... "2023-02-10", ... "2023-02-15", ... ] ... ), ... ) >>> ser.resample("MS").ohlc() open high low close 2023-01-01 1 3 1 2 2023-02-01 4 5 3 5