Skip to content

Commit 80b2b69

Browse files
committed
Merge branch 'main' into pandas-devgh-52343-timestamp-from-positional
2 parents acefe47 + 705d431 commit 80b2b69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1921
-886
lines changed

.circleci/config.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
name: Build aarch64 wheels
4949
no_output_timeout: 30m # Sometimes the tests won't generate any output, make sure the job doesn't get killed by that
5050
command: |
51-
pip3 install cibuildwheel==2.14.1
51+
pip3 install cibuildwheel==2.15.0
5252
cibuildwheel --prerelease-pythons --output-dir wheelhouse
5353
environment:
5454
CIBW_BUILD: << parameters.cibw-build >>
@@ -92,5 +92,4 @@ workflows:
9292
only: /^v.*/
9393
matrix:
9494
parameters:
95-
# TODO: Enable Python 3.12 wheels when numpy releases a version that supports Python 3.12
96-
cibw-build: ["cp39-manylinux_aarch64", "cp310-manylinux_aarch64", "cp311-manylinux_aarch64"]#, "cp312-manylinux_aarch64"]
95+
cibw-build: ["cp39-manylinux_aarch64", "cp310-manylinux_aarch64", "cp311-manylinux_aarch64", "cp312-manylinux_aarch64"]

.github/workflows/code-checks.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
steps:
3535
- name: Checkout
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737
with:
3838
fetch-depth: 0
3939

@@ -109,7 +109,7 @@ jobs:
109109

110110
steps:
111111
- name: Checkout
112-
uses: actions/checkout@v3
112+
uses: actions/checkout@v4
113113
with:
114114
fetch-depth: 0
115115

@@ -143,7 +143,7 @@ jobs:
143143
run: docker image prune -f
144144

145145
- name: Checkout
146-
uses: actions/checkout@v3
146+
uses: actions/checkout@v4
147147
with:
148148
fetch-depth: 0
149149

@@ -164,7 +164,7 @@ jobs:
164164

165165
steps:
166166
- name: Checkout
167-
uses: actions/checkout@v3
167+
uses: actions/checkout@v4
168168
with:
169169
fetch-depth: 0
170170

.github/workflows/codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- python
2828

2929
steps:
30-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
3131
- uses: github/codeql-action/init@v2
3232
with:
3333
languages: ${{ matrix.language }}

.github/workflows/comment-commands.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v3
54+
uses: actions/checkout@v4
5555
with:
5656
fetch-depth: 0
5757

.github/workflows/docbuild-and-upload.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: Checkout
39-
uses: actions/checkout@v3
39+
uses: actions/checkout@v4
4040
with:
4141
fetch-depth: 0
4242

.github/workflows/package-checks.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
steps:
3636
- name: Checkout
37-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
3838
with:
3939
fetch-depth: 0
4040

@@ -62,7 +62,7 @@ jobs:
6262
cancel-in-progress: true
6363
steps:
6464
- name: Checkout
65-
uses: actions/checkout@v3
65+
uses: actions/checkout@v4
6666
with:
6767
fetch-depth: 0
6868

.github/workflows/unit-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136

137137
steps:
138138
- name: Checkout
139-
uses: actions/checkout@v3
139+
uses: actions/checkout@v4
140140
with:
141141
fetch-depth: 0
142142

@@ -194,7 +194,7 @@ jobs:
194194

195195
steps:
196196
- name: Checkout
197-
uses: actions/checkout@v3
197+
uses: actions/checkout@v4
198198
with:
199199
fetch-depth: 0
200200

@@ -330,7 +330,7 @@ jobs:
330330
PYTEST_TARGET: pandas
331331

332332
steps:
333-
- uses: actions/checkout@v3
333+
- uses: actions/checkout@v4
334334
with:
335335
fetch-depth: 0
336336

.github/workflows/wheels.yml

+11-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
sdist_file: ${{ steps.save-path.outputs.sdist_name }}
4949
steps:
5050
- name: Checkout pandas
51-
uses: actions/checkout@v3
51+
uses: actions/checkout@v4
5252
with:
5353
fetch-depth: 0
5454

@@ -97,14 +97,13 @@ jobs:
9797
- [macos-12, macosx_*]
9898
- [windows-2022, win_amd64]
9999
# TODO: support PyPy?
100-
# TODO: Enable Python 3.12 wheels when numpy releases a version that supports Python 3.12
101-
python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"]]#, ["cp312", "3.12"]]
100+
python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
102101
env:
103102
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
104103
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
105104
steps:
106105
- name: Checkout pandas
107-
uses: actions/checkout@v3
106+
uses: actions/checkout@v4
108107
with:
109108
fetch-depth: 0
110109

@@ -150,8 +149,10 @@ jobs:
150149
uses: mamba-org/setup-micromamba@v1
151150
with:
152151
environment-name: wheel-env
152+
# Use a fixed Python, since we might have an unreleased Python not
153+
# yet present on conda-forge
153154
create-args: >-
154-
python=${{ matrix.python[1] }}
155+
python=3.11
155156
anaconda-client
156157
wheel
157158
cache-downloads: true
@@ -167,12 +168,13 @@ jobs:
167168
shell: pwsh
168169
run: |
169170
$TST_CMD = @"
170-
python -m pip install pytz six numpy python-dateutil tzdata>=2022.1 hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17;
171-
python -m pip install --find-links=pandas\wheelhouse --no-index pandas;
171+
python -m pip install hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17;
172+
python -m pip install `$(Get-Item pandas\wheelhouse\*.whl);
172173
python -c `'import pandas as pd; pd.test(extra_args=[\"`\"--no-strict-data-files`\"\", \"`\"-m not clipboard and not single_cpu and not slow and not network and not db`\"\"])`';
173174
"@
174-
docker pull python:${{ matrix.python[1] }}-windowsservercore
175-
docker run --env PANDAS_CI='1' -v ${PWD}:C:\pandas python:${{ matrix.python[1] }}-windowsservercore powershell -Command $TST_CMD
175+
# add rc to the end of the image name if the Python version is unreleased
176+
docker pull python:${{ matrix.python[1] == '3.12' && '3.12-rc' || format('{0}-windowsservercore', matrix.python[1]) }}
177+
docker run --env PANDAS_CI='1' -v ${PWD}:C:\pandas python:${{ matrix.python[1] == '3.12' && '3.12-rc' || format('{0}-windowsservercore', matrix.python[1]) }} powershell -Command $TST_CMD
176178
177179
- uses: actions/upload-artifact@v3
178180
with:

doc/source/user_guide/cookbook.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ Unlike agg, apply's callable is passed a sub-DataFrame which gives you access to
459459
df
460460
461461
# List the size of the animals with the highest weight.
462-
df.groupby("animal").apply(lambda subf: subf["size"][subf["weight"].idxmax()])
462+
df.groupby("animal").apply(lambda subf: subf["size"][subf["weight"].idxmax()], include_groups=False)
463463
464464
`Using get_group
465465
<https://stackoverflow.com/questions/14734533/how-to-access-pandas-groupby-dataframe-by-key>`__
@@ -482,7 +482,7 @@ Unlike agg, apply's callable is passed a sub-DataFrame which gives you access to
482482
return pd.Series(["L", avg_weight, True], index=["size", "weight", "adult"])
483483
484484
485-
expected_df = gb.apply(GrowUp)
485+
expected_df = gb.apply(GrowUp, include_groups=False)
486486
expected_df
487487
488488
`Expanding apply

doc/source/user_guide/groupby.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ This is mainly syntactic sugar for the alternative, which is much more verbose:
420420
Additionally, this method avoids recomputing the internal grouping information
421421
derived from the passed key.
422422

423+
You can also include the grouping columns if you want to operate on them.
424+
425+
.. ipython:: python
426+
427+
grouped[["A", "B"]].sum()
428+
423429
.. _groupby.iterating-label:
424430

425431
Iterating through groups
@@ -1053,7 +1059,7 @@ missing values with the ``ffill()`` method.
10531059
).set_index("date")
10541060
df_re
10551061
1056-
df_re.groupby("group").resample("1D").ffill()
1062+
df_re.groupby("group").resample("1D", include_groups=False).ffill()
10571063
10581064
.. _groupby.filter:
10591065

@@ -1219,13 +1225,13 @@ the argument ``group_keys`` which defaults to ``True``. Compare
12191225

12201226
.. ipython:: python
12211227
1222-
df.groupby("A", group_keys=True).apply(lambda x: x)
1228+
df.groupby("A", group_keys=True).apply(lambda x: x, include_groups=False)
12231229
12241230
with
12251231

12261232
.. ipython:: python
12271233
1228-
df.groupby("A", group_keys=False).apply(lambda x: x)
1234+
df.groupby("A", group_keys=False).apply(lambda x: x, include_groups=False)
12291235
12301236
12311237
Numba Accelerated Routines
@@ -1709,7 +1715,7 @@ column index name will be used as the name of the inserted column:
17091715
result = {"b_sum": x["b"].sum(), "c_mean": x["c"].mean()}
17101716
return pd.Series(result, name="metrics")
17111717
1712-
result = df.groupby("a").apply(compute_metrics)
1718+
result = df.groupby("a").apply(compute_metrics, include_groups=False)
17131719
17141720
result
17151721

doc/source/whatsnew/v0.10.0.rst

+30-13
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,36 @@ labeled the aggregated group with the end of the interval: the next day).
180180
DataFrame constructor with no columns specified. The v0.9.0 behavior (names
181181
``X0``, ``X1``, ...) can be reproduced by specifying ``prefix='X'``:
182182

183-
.. ipython:: python
184-
:okexcept:
185-
186-
import io
187-
188-
data = """
189-
a,b,c
190-
1,Yes,2
191-
3,No,4
192-
"""
193-
print(data)
194-
pd.read_csv(io.StringIO(data), header=None)
195-
pd.read_csv(io.StringIO(data), header=None, prefix="X")
183+
.. code-block:: ipython
184+
185+
In [6]: import io
186+
187+
In [7]: data = """
188+
...: a,b,c
189+
...: 1,Yes,2
190+
...: 3,No,4
191+
...: """
192+
...:
193+
194+
In [8]: print(data)
195+
196+
a,b,c
197+
1,Yes,2
198+
3,No,4
199+
200+
In [9]: pd.read_csv(io.StringIO(data), header=None)
201+
Out[9]:
202+
0 1 2
203+
0 a b c
204+
1 1 Yes 2
205+
2 3 No 4
206+
207+
In [10]: pd.read_csv(io.StringIO(data), header=None, prefix="X")
208+
Out[10]:
209+
X0 X1 X2
210+
0 a b c
211+
1 1 Yes 2
212+
2 3 No 4
196213
197214
- Values like ``'Yes'`` and ``'No'`` are not interpreted as boolean by default,
198215
though this can be controlled by new ``true_values`` and ``false_values``

doc/source/whatsnew/v0.14.0.rst

+16-5
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,24 @@ More consistent behavior for some groupby methods:
328328

329329
- groupby ``head`` and ``tail`` now act more like ``filter`` rather than an aggregation:
330330

331-
.. ipython:: python
331+
.. code-block:: ipython
332332
333-
df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], columns=['A', 'B'])
334-
g = df.groupby('A')
335-
g.head(1) # filters DataFrame
333+
In [1]: df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], columns=['A', 'B'])
336334
337-
g.apply(lambda x: x.head(1)) # used to simply fall-through
335+
In [2]: g = df.groupby('A')
336+
337+
In [3]: g.head(1) # filters DataFrame
338+
Out[3]:
339+
A B
340+
0 1 2
341+
2 5 6
342+
343+
In [4]: g.apply(lambda x: x.head(1)) # used to simply fall-through
344+
Out[4]:
345+
A B
346+
A
347+
1 0 1 2
348+
5 2 5 6
338349
339350
- groupby head and tail respect column selection:
340351

0 commit comments

Comments
 (0)