Skip to content

Commit 69f6c1c

Browse files
authored
Merge pull request #41 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents b7a41e8 + 4181042 commit 69f6c1c

File tree

9 files changed

+1116
-1108
lines changed

9 files changed

+1116
-1108
lines changed

doc/source/whatsnew/v1.0.2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Fixed regressions
1818
- Fixed regression in :meth:`DataFrame.to_excel` when ``columns`` kwarg is passed (:issue:`31677`)
1919
- Fixed regression in :meth:`Series.align` when ``other`` is a DataFrame and ``method`` is not None (:issue:`31785`)
2020
- Fixed regression in :meth:`pandas.core.groupby.RollingGroupby.apply` where the ``raw`` parameter was ignored (:issue:`31754`)
21+
- Fixed regression in :meth:`rolling(..).corr() <pandas.core.window.Rolling.corr>` when using a time offset (:issue:`31789`)
2122
-
2223

2324
.. ---------------------------------------------------------------------------

pandas/core/frame.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5222,7 +5222,7 @@ def nsmallest(self, n, columns, keep="first") -> "DataFrame":
52225222
Examples
52235223
--------
52245224
>>> df = pd.DataFrame({'population': [59000000, 65000000, 434000,
5225-
... 434000, 434000, 337000, 11300,
5225+
... 434000, 434000, 337000, 337000,
52265226
... 11300, 11300],
52275227
... 'GDP': [1937894, 2583560 , 12011, 4520, 12128,
52285228
... 17036, 182, 38, 311],
@@ -5239,43 +5239,44 @@ def nsmallest(self, n, columns, keep="first") -> "DataFrame":
52395239
Maldives 434000 4520 MV
52405240
Brunei 434000 12128 BN
52415241
Iceland 337000 17036 IS
5242-
Nauru 11300 182 NR
5242+
Nauru 337000 182 NR
52435243
Tuvalu 11300 38 TV
52445244
Anguilla 11300 311 AI
52455245
52465246
In the following example, we will use ``nsmallest`` to select the
5247-
three rows having the smallest values in column "a".
5247+
three rows having the smallest values in column "population".
52485248
52495249
>>> df.nsmallest(3, 'population')
5250-
population GDP alpha-2
5251-
Nauru 11300 182 NR
5252-
Tuvalu 11300 38 TV
5253-
Anguilla 11300 311 AI
5250+
population GDP alpha-2
5251+
Tuvalu 11300 38 TV
5252+
Anguilla 11300 311 AI
5253+
Iceland 337000 17036 IS
52545254
52555255
When using ``keep='last'``, ties are resolved in reverse order:
52565256
52575257
>>> df.nsmallest(3, 'population', keep='last')
52585258
population GDP alpha-2
52595259
Anguilla 11300 311 AI
52605260
Tuvalu 11300 38 TV
5261-
Nauru 11300 182 NR
5261+
Nauru 337000 182 NR
52625262
52635263
When using ``keep='all'``, all duplicate items are maintained:
52645264
52655265
>>> df.nsmallest(3, 'population', keep='all')
5266-
population GDP alpha-2
5267-
Nauru 11300 182 NR
5268-
Tuvalu 11300 38 TV
5269-
Anguilla 11300 311 AI
5266+
population GDP alpha-2
5267+
Tuvalu 11300 38 TV
5268+
Anguilla 11300 311 AI
5269+
Iceland 337000 17036 IS
5270+
Nauru 337000 182 NR
52705271
5271-
To order by the largest values in column "a" and then "c", we can
5272+
To order by the smallest values in column "population" and then "GDP", we can
52725273
specify multiple columns like in the next example.
52735274
52745275
>>> df.nsmallest(3, ['population', 'GDP'])
52755276
population GDP alpha-2
52765277
Tuvalu 11300 38 TV
5277-
Nauru 11300 182 NR
52785278
Anguilla 11300 311 AI
5279+
Nauru 337000 182 NR
52795280
"""
52805281
return algorithms.SelectNFrame(
52815282
self, n=n, keep=keep, columns=columns

pandas/core/generic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3498,13 +3498,11 @@ def _iget_item_cache(self, item):
34983498
def _box_item_values(self, key, values):
34993499
raise AbstractMethodError(self)
35003500

3501-
def _slice(
3502-
self: FrameOrSeries, slobj: slice, axis=0, kind: str = "getitem"
3503-
) -> FrameOrSeries:
3501+
def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries:
35043502
"""
35053503
Construct a slice of this container.
35063504
3507-
kind parameter is maintained for compatibility with Series slicing.
3505+
Slicing with this method is *always* positional.
35083506
"""
35093507
axis = self._get_block_manager_axis(axis)
35103508
result = self._constructor(self._data.get_slice(slobj, axis=axis))

0 commit comments

Comments
 (0)