diff --git a/doc/source/user_guide/enhancingperf.rst b/doc/source/user_guide/enhancingperf.rst index 647b0f760f4d4..dbd52911674f3 100644 --- a/doc/source/user_guide/enhancingperf.rst +++ b/doc/source/user_guide/enhancingperf.rst @@ -81,6 +81,7 @@ Let's take a look and see where the time is spent during this operation using the `prun ipython magic function `__: .. ipython:: python + :okexcept: # most time consuming 4 calls %prun -l 4 df.apply(lambda x: integrate_f(x["a"], x["b"], x["N"]), axis=1) # noqa E999 @@ -163,6 +164,7 @@ the index and the series (three times for each row). These Python function calls can be improved by passing an ``np.ndarray``. .. ipython:: python + :okexcept: %prun -l 4 df.apply(lambda x: integrate_f_typed(x["a"], x["b"], x["N"]), axis=1) @@ -203,6 +205,7 @@ Since ``apply_integrate_f`` is typed to accept an ``np.ndarray``, :meth:`Series. calls are needed to utilize this function. .. ipython:: python + :okexcept: %timeit apply_integrate_f(df["a"].to_numpy(), df["b"].to_numpy(), df["N"].to_numpy()) @@ -217,6 +220,7 @@ The majority of the time is now spent in ``apply_integrate_f``. Disabling Cython and ``wraparound`` checks can yield more performance. .. ipython:: python + :okexcept: %prun -l 4 apply_integrate_f(df["a"].to_numpy(), df["b"].to_numpy(), df["N"].to_numpy()) @@ -252,6 +256,7 @@ and ``wraparound`` checks can yield more performance. ...: .. ipython:: python + :okexcept: %timeit apply_integrate_f_wrap(df["a"].to_numpy(), df["b"].to_numpy(), df["N"].to_numpy()) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index a16964435ef50..21332324af552 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1,3 +1,5 @@ +# cython: embedsignature=True + import re import time import warnings @@ -1177,6 +1179,11 @@ cdef class Day(Tick): """ Offset ``n`` days. + Parameters + ---------- + n : int + Number of multiples of the frequency (default 1). + Attributes ---------- n : int, default 1 @@ -1208,6 +1215,8 @@ cdef class Day(Tick): _period_dtype_code = PeriodDtypeCode.D _creso = NPY_DATETIMEUNIT.NPY_FR_D + def __init__(self, n=1, normalize=False): + super().__init__(n, normalize) cdef class Hour(Tick): """ @@ -5108,8 +5117,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str: warnings.warn( f"\'{name}\' is deprecated and will be removed " f"in a future version, please use " - f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\'" - f" instead.", + f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\' " + f"instead.", FutureWarning, stacklevel=find_stack_level(), ) @@ -5122,8 +5131,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str: warnings.warn( f"\'{name}\' is deprecated and will be removed " f"in a future version, please use " - f"\'{_name}\'" - f" instead.", + f"\'{_name}\' " + f"instead.", FutureWarning, stacklevel=find_stack_level(), )