Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/pypa/cibuildwheel-…
Browse files Browse the repository at this point in the history
…2.22.0
  • Loading branch information
mroeschke authored Nov 25, 2024
2 parents dbce169 + 0b6cece commit da436a7
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
6 changes: 0 additions & 6 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.core.resample.Resampler.std SA01" \
-i "pandas.core.resample.Resampler.transform PR01,RT03,SA01" \
-i "pandas.core.resample.Resampler.var SA01" \
-i "pandas.errors.DuplicateLabelError SA01" \
-i "pandas.errors.IntCastingNaNError SA01" \
-i "pandas.errors.InvalidIndexError SA01" \
-i "pandas.errors.NullFrequencyError SA01" \
-i "pandas.errors.NumExprClobberingError SA01" \
-i "pandas.errors.NumbaUtilError SA01" \
-i "pandas.errors.OutOfBoundsTimedelta SA01" \
-i "pandas.errors.PerformanceWarning SA01" \
-i "pandas.errors.PossibleDataLossError SA01" \
-i "pandas.errors.UndefinedVariableError PR01,SA01" \
-i "pandas.errors.UnsortedIndexError SA01" \
-i "pandas.errors.ValueLabelTypeMismatch SA01" \
-i "pandas.infer_freq SA01" \
-i "pandas.io.json.build_table_schema PR07,RT03,SA01" \
Expand Down
6 changes: 3 additions & 3 deletions doc/source/user_guide/window.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ One must have :math:`0 < \alpha \leq 1`, and while it is possible to pass
\alpha =
\begin{cases}
\frac{2}{s + 1}, & \text{for span}\ s \geq 1\\
\frac{1}{1 + c}, & \text{for center of mass}\ c \geq 0\\
1 - \exp^{\frac{\log 0.5}{h}}, & \text{for half-life}\ h > 0
\frac{2}{s + 1}, & \text{for span}\ s \geq 1\\
\frac{1}{1 + c}, & \text{for center of mass}\ c \geq 0\\
1 - e^{\frac{\log 0.5}{h}}, & \text{for half-life}\ h > 0
\end{cases}
One must specify precisely one of **span**, **center of mass**, **half-life**
Expand Down
4 changes: 4 additions & 0 deletions pandas/_libs/tslibs/np_datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ class OutOfBoundsTimedelta(ValueError):
Representation should be within a timedelta64[ns].
See Also
--------
date_range : Return a fixed frequency DatetimeIndex.
Examples
--------
>>> pd.date_range(start="1/1/1700", freq="B", periods=100000)
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,9 @@ def shift(self, periods: int = 1, fill_value: object = None) -> IntervalArray:
from pandas import Index

fill_value = Index(self._left, copy=False)._na_value
empty = IntervalArray.from_breaks([fill_value] * (empty_len + 1))
empty = IntervalArray.from_breaks(
[fill_value] * (empty_len + 1), closed=self.closed
)
else:
empty = self._from_sequence([fill_value] * empty_len, dtype=self.dtype)

Expand Down
42 changes: 42 additions & 0 deletions pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class UnsortedIndexError(KeyError):
Subclass of `KeyError`.
See Also
--------
DataFrame.sort_index : Sort a DataFrame by its index.
DataFrame.set_index : Set the DataFrame index using existing columns.
Examples
--------
>>> df = pd.DataFrame(
Expand Down Expand Up @@ -388,6 +393,19 @@ class DuplicateLabelError(ValueError):
"""
Error raised when an operation would introduce duplicate labels.
This error is typically encountered when performing operations on objects
with `allows_duplicate_labels=False` and the operation would result in
duplicate labels in the index. Duplicate labels can lead to ambiguities
in indexing and reduce data integrity.
See Also
--------
Series.set_flags : Return a new ``Series`` object with updated flags.
DataFrame.set_flags : Return a new ``DataFrame`` object with updated flags.
Series.reindex : Conform ``Series`` object to new index with optional filling logic.
DataFrame.reindex : Conform ``DataFrame`` object to new index with optional filling
logic.
Examples
--------
>>> s = pd.Series([0, 1, 2], index=["a", "b", "c"]).set_flags(
Expand All @@ -407,6 +425,16 @@ class InvalidIndexError(Exception):
"""
Exception raised when attempting to use an invalid index key.
This exception is triggered when a user attempts to access or manipulate
data in a pandas DataFrame or Series using an index key that is not valid
for the given object. This may occur in cases such as using a malformed
slice, a mismatched key for a ``MultiIndex``, or attempting to access an index
element that does not exist.
See Also
--------
MultiIndex : A multi-level, or hierarchical, index object for pandas objects.
Examples
--------
>>> idx = pd.MultiIndex.from_product([["x", "y"], [0, 1]])
Expand Down Expand Up @@ -510,6 +538,11 @@ class NumExprClobberingError(NameError):
to 'numexpr'. 'numexpr' is the default engine value for these methods if the
numexpr package is installed.
See Also
--------
eval : Evaluate a Python expression as a string using various backends.
DataFrame.query : Query the columns of a DataFrame with a boolean expression.
Examples
--------
>>> df = pd.DataFrame({"abs": [1, 1, 1]})
Expand Down Expand Up @@ -633,6 +666,15 @@ class PossibleDataLossError(Exception):
"""
Exception raised when trying to open a HDFStore file when already opened.
This error is triggered when there is a potential risk of data loss due to
conflicting operations on an HDFStore file. It serves to prevent unintended
overwrites or data corruption by enforcing exclusive access to the file.
See Also
--------
HDFStore : Dict-like IO interface for storing pandas objects in PyTables.
HDFStore.open : Open an HDFStore file in the specified mode.
Examples
--------
>>> store = pd.HDFStore("my-store", "a") # doctest: +SKIP
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/frame/methods/test_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,3 +757,12 @@ def test_shift_with_offsets_freq_empty(self):
df_shifted = DataFrame(index=shifted_dates)
result = df.shift(freq=offset)
tm.assert_frame_equal(result, df_shifted)

def test_series_shift_interval_preserves_closed(self):
# GH#60389
ser = Series(
[pd.Interval(1, 2, closed="right"), pd.Interval(2, 3, closed="right")]
)
result = ser.shift(1)
expected = Series([np.nan, pd.Interval(1, 2, closed="right")])
tm.assert_series_equal(result, expected)
2 changes: 1 addition & 1 deletion pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ def test_value_counts_nat(self):
result_dt = algos.value_counts_internal(dt)
tm.assert_series_equal(result_dt, exp_dt)

exp_td = Series({np.timedelta64(10000): 1}, name="count")
exp_td = Series([1], index=[np.timedelta64(10000)], name="count")
result_td = algos.value_counts_internal(td)
tm.assert_series_equal(result_td, exp_td)

Expand Down

0 comments on commit da436a7

Please sign in to comment.