Skip to content

Commit cc86ce2

Browse files
Merge branch 'pandas-dev:main' into fix/combine_first-bug
2 parents 881f523 + 5126dca commit cc86ce2

File tree

9 files changed

+65
-6
lines changed

9 files changed

+65
-6
lines changed

.github/workflows/package-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
fetch-depth: 0
6868

6969
- name: Set up Python
70-
uses: mamba-org/setup-micromamba@v1
70+
uses: mamba-org/setup-micromamba@v2
7171
with:
7272
environment-name: recipe-test
7373
create-args: >-

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
CIBW_PLATFORM: ${{ matrix.buildplat[1] == 'pyodide_wasm32' && 'pyodide' || 'auto' }}
166166

167167
- name: Set up Python
168-
uses: mamba-org/setup-micromamba@v1
168+
uses: mamba-org/setup-micromamba@v2
169169
with:
170170
environment-name: wheel-env
171171
# Use a fixed Python, since we might have an unreleased Python not

ci/code_checks.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
174174
-i "pandas.errors.ValueLabelTypeMismatch SA01" \
175175
-i "pandas.infer_freq SA01" \
176176
-i "pandas.io.json.build_table_schema PR07,RT03,SA01" \
177-
-i "pandas.io.stata.StataReader.value_labels RT03,SA01" \
178177
-i "pandas.io.stata.StataReader.variable_labels RT03,SA01" \
179178
-i "pandas.io.stata.StataWriter.write_file SA01" \
180179
-i "pandas.json_normalize RT03,SA01" \
181180
-i "pandas.plotting.andrews_curves RT03,SA01" \
182-
-i "pandas.plotting.lag_plot RT03,SA01" \
183181
-i "pandas.plotting.scatter_matrix PR07,SA01" \
184182
-i "pandas.set_eng_float_format RT03,SA01" \
185183
-i "pandas.tseries.offsets.BDay PR02,SA01" \

pandas/_libs/tslibs/nattype.pyi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from typing import (
99
Literal,
1010
NoReturn,
1111
TypeAlias,
12+
overload,
1213
)
1314

1415
import numpy as np
@@ -159,15 +160,31 @@ class NaTType:
159160
# inject Period properties
160161
@property
161162
def qyear(self) -> float: ...
163+
# comparisons
162164
def __eq__(self, other: object) -> bool: ...
163165
def __ne__(self, other: object) -> bool: ...
164166
__lt__: _NatComparison
165167
__le__: _NatComparison
166168
__gt__: _NatComparison
167169
__ge__: _NatComparison
170+
# unary operators
171+
def __pos__(self) -> Self: ...
172+
def __neg__(self) -> Self: ...
173+
# binary operators
168174
def __sub__(self, other: Self | timedelta | datetime) -> Self: ...
169175
def __rsub__(self, other: Self | timedelta | datetime) -> Self: ...
170176
def __add__(self, other: Self | timedelta | datetime) -> Self: ...
171177
def __radd__(self, other: Self | timedelta | datetime) -> Self: ...
178+
def __mul__(self, other: float) -> Self: ... # analogous to timedelta
179+
def __rmul__(self, other: float) -> Self: ...
180+
@overload # analogous to timedelta
181+
def __truediv__(self, other: Self | timedelta) -> float: ... # Literal[NaN]
182+
@overload
183+
def __truediv__(self, other: float) -> Self: ...
184+
@overload # analogous to timedelta
185+
def __floordiv__(self, other: Self | timedelta) -> float: ... # Literal[NaN]
186+
@overload
187+
def __floordiv__(self, other: float) -> Self: ...
188+
# other
172189
def __hash__(self) -> int: ...
173190
def as_unit(self, unit: str, round_ok: bool = ...) -> NaTType: ...

pandas/core/groupby/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def _ob_index_and_ids(
867867
names=names,
868868
verify_integrity=False,
869869
)
870-
if not consistent_sorting:
870+
if not consistent_sorting and len(ob_index) > 0:
871871
# Sort by the levels where the corresponding sort argument is True
872872
n_levels = len(sorts)
873873
drop_levels = [

pandas/core/reshape/encoding.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def get_dummies(
6868
If appending prefix, separator/delimiter to use. Or pass a
6969
list or dictionary as with `prefix`.
7070
dummy_na : bool, default False
71-
Add a column to indicate NaNs, if False NaNs are ignored.
71+
If True, a NaN indicator column will be added even if no NaN values are present.
72+
If False, NA values are encoded as all zero.
7273
columns : list-like, default None
7374
Column names in the DataFrame to be encoded.
7475
If `columns` is None then all the columns with

pandas/io/stata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,9 +2076,19 @@ def value_labels(self) -> dict[str, dict[int, str]]:
20762076
"""
20772077
Return a nested dict associating each variable name to its value and label.
20782078
2079+
This method retrieves the value labels from a Stata file. Value labels are
2080+
mappings between the coded values and their corresponding descriptive labels
2081+
in a Stata dataset.
2082+
20792083
Returns
20802084
-------
20812085
dict
2086+
A python dictionary.
2087+
2088+
See Also
2089+
--------
2090+
read_stata : Read Stata file into DataFrame.
2091+
DataFrame.to_stata : Export DataFrame object to Stata dta format.
20822092
20832093
Examples
20842094
--------

pandas/plotting/_misc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,10 @@ def lag_plot(series: Series, lag: int = 1, ax: Axes | None = None, **kwds) -> Ax
549549
"""
550550
Lag plot for time series.
551551
552+
A lag plot is a scatter plot of a time series against a lag of itself. It helps
553+
in visualizing the temporal dependence between observations by plotting the values
554+
at time `t` on the x-axis and the values at time `t + lag` on the y-axis.
555+
552556
Parameters
553557
----------
554558
series : Series
@@ -563,6 +567,13 @@ def lag_plot(series: Series, lag: int = 1, ax: Axes | None = None, **kwds) -> Ax
563567
Returns
564568
-------
565569
matplotlib.axes.Axes
570+
The matplotlib Axes object containing the lag plot.
571+
572+
See Also
573+
--------
574+
plotting.autocorrelation_plot : Autocorrelation plot for time series.
575+
matplotlib.pyplot.scatter : A scatter plot of y vs. x with varying marker size
576+
and/or color in Matplotlib.
566577
567578
Examples
568579
--------

pandas/tests/groupby/methods/test_value_counts.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,3 +1219,25 @@ def test_value_counts_sort_categorical(sort, vc_sort, normalize):
12191219
expected = expected.take(taker)
12201220

12211221
tm.assert_series_equal(result, expected)
1222+
1223+
1224+
@pytest.mark.parametrize("groupby_sort", [True, False])
1225+
def test_value_counts_all_na(sort, dropna, groupby_sort):
1226+
# GH#59989
1227+
df = DataFrame({"a": [2, 1, 1], "b": np.nan})
1228+
gb = df.groupby("a", sort=groupby_sort)
1229+
result = gb.value_counts(sort=sort, dropna=dropna)
1230+
1231+
kwargs = {"levels": [[1, 2], [np.nan]], "names": ["a", "b"]}
1232+
if dropna:
1233+
data = []
1234+
index = MultiIndex(codes=[[], []], **kwargs)
1235+
elif not groupby_sort and not sort:
1236+
data = [1, 2]
1237+
index = MultiIndex(codes=[[1, 0], [0, 0]], **kwargs)
1238+
else:
1239+
data = [2, 1]
1240+
index = MultiIndex(codes=[[0, 1], [0, 0]], **kwargs)
1241+
expected = Series(data, index=index, dtype="int64", name="count")
1242+
1243+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)