Skip to content

Commit f93374c

Browse files
committed
Merge branch 'main' of https://github.com/pandas-dev/pandas into implement_pdep17
2 parents ce08582 + bd9f060 commit f93374c

File tree

12 files changed

+50
-24
lines changed

12 files changed

+50
-24
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
LANG: ${{ matrix.lang || 'C.UTF-8' }}
9292
LC_ALL: ${{ matrix.lc_all || '' }}
9393
PANDAS_CI: '1'
94-
PANDAS_FUTURE_INFER_STRING: ${{ matrix.pandas_future_infer_string || '0' }}
94+
PANDAS_FUTURE_INFER_STRING: ${{ matrix.pandas_future_infer_string || '1' }}
9595
TEST_ARGS: ${{ matrix.test_args || '' }}
9696
PYTEST_WORKERS: 'auto'
9797
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }}

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ Other Deprecations
469469
- Deprecated :meth:`.DataFrameGroupby.corrwith` (:issue:`57158`)
470470
- Deprecated :meth:`Timestamp.utcfromtimestamp`, use ``Timestamp.fromtimestamp(ts, "UTC")`` instead (:issue:`56680`)
471471
- Deprecated :meth:`Timestamp.utcnow`, use ``Timestamp.now("UTC")`` instead (:issue:`56680`)
472+
- Deprecated ``pd.core.internals.api.maybe_infer_ndim`` (:issue:`40226`)
472473
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.all`, :meth:`DataFrame.min`, :meth:`DataFrame.max`, :meth:`DataFrame.sum`, :meth:`DataFrame.prod`, :meth:`DataFrame.mean`, :meth:`DataFrame.median`, :meth:`DataFrame.sem`, :meth:`DataFrame.var`, :meth:`DataFrame.std`, :meth:`DataFrame.skew`, :meth:`DataFrame.kurt`, :meth:`Series.all`, :meth:`Series.min`, :meth:`Series.max`, :meth:`Series.sum`, :meth:`Series.prod`, :meth:`Series.mean`, :meth:`Series.median`, :meth:`Series.sem`, :meth:`Series.var`, :meth:`Series.std`, :meth:`Series.skew`, and :meth:`Series.kurt`. (:issue:`57087`)
473474
- Deprecated allowing non-keyword arguments in :meth:`Series.to_markdown` except ``buf``. (:issue:`57280`)
474475
- Deprecated allowing non-keyword arguments in :meth:`Series.to_string` except ``buf``. (:issue:`57280`)

pandas/_libs/internals.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,9 @@ cdef class Block:
709709
self.ndim = state[2]
710710
else:
711711
# older pickle
712-
from pandas.core.internals.api import maybe_infer_ndim
712+
from pandas.core.internals.api import _maybe_infer_ndim
713713

714-
ndim = maybe_infer_ndim(self.values, self.mgr_locs)
714+
ndim = _maybe_infer_ndim(self.values, self.mgr_locs)
715715
self.ndim = ndim
716716

717717
cpdef Block slice_block_rows(self, slice slicer):

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
17781778
>>> rng.strftime("%%B %%d, %%Y, %%r")
17791779
Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
17801780
'March 10, 2018, 09:00:02 AM'],
1781-
dtype='object')
1781+
dtype='str')
17821782
"""
17831783
result = self._format_native_types(date_format=date_format, na_rep=np.nan)
17841784
if using_string_dtype():

pandas/core/arrays/datetimes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,14 +1308,14 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
13081308
0 January
13091309
1 February
13101310
2 March
1311-
dtype: object
1311+
dtype: str
13121312
13131313
>>> idx = pd.date_range(start="2018-01", freq="ME", periods=3)
13141314
>>> idx
13151315
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
13161316
dtype='datetime64[ns]', freq='ME')
13171317
>>> idx.month_name()
1318-
Index(['January', 'February', 'March'], dtype='object')
1318+
Index(['January', 'February', 'March'], dtype='str')
13191319
13201320
Using the ``locale`` parameter you can set a different locale language,
13211321
for example: ``idx.month_name(locale='pt_BR.utf8')`` will return month
@@ -1326,7 +1326,7 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
13261326
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
13271327
dtype='datetime64[ns]', freq='ME')
13281328
>>> idx.month_name(locale="pt_BR.utf8") # doctest: +SKIP
1329-
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object')
1329+
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='str')
13301330
"""
13311331
values = self._local_timestamps()
13321332

@@ -1376,14 +1376,14 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
13761376
0 Monday
13771377
1 Tuesday
13781378
2 Wednesday
1379-
dtype: object
1379+
dtype: str
13801380
13811381
>>> idx = pd.date_range(start="2018-01-01", freq="D", periods=3)
13821382
>>> idx
13831383
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
13841384
dtype='datetime64[ns]', freq='D')
13851385
>>> idx.day_name()
1386-
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')
1386+
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='str')
13871387
13881388
Using the ``locale`` parameter you can set a different locale language,
13891389
for example: ``idx.day_name(locale='pt_BR.utf8')`` will return day
@@ -1394,7 +1394,7 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
13941394
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
13951395
dtype='datetime64[ns]', freq='D')
13961396
>>> idx.day_name(locale="pt_BR.utf8") # doctest: +SKIP
1397-
Index(['Segunda', 'Terça', 'Quarta'], dtype='object')
1397+
Index(['Segunda', 'Terça', 'Quarta'], dtype='str')
13981398
"""
13991399
values = self._local_timestamps()
14001400

pandas/core/generic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ def keys(self) -> Index:
19191919
b 2 4
19201920
c 3 8
19211921
>>> d.keys()
1922-
Index(['A', 'B'], dtype='object')
1922+
Index(['A', 'B'], dtype='str')
19231923
"""
19241924
return self._info_axis
19251925

@@ -6277,7 +6277,7 @@ def dtypes(self):
62776277
float float64
62786278
int int64
62796279
datetime datetime64[s]
6280-
string object
6280+
string str
62816281
dtype: object
62826282
"""
62836283
data = self._mgr.get_dtypes()
@@ -6839,7 +6839,7 @@ def convert_dtypes(
68396839
0 a
68406840
1 b
68416841
2 NaN
6842-
dtype: object
6842+
dtype: str
68436843
68446844
Obtain a Series with dtype ``StringDtype``.
68456845
@@ -8139,7 +8139,7 @@ def isna(self) -> Self:
81398139
... )
81408140
>>> df
81418141
age born name toy
8142-
0 5.0 NaT Alfred None
8142+
0 5.0 NaT Alfred NaN
81438143
1 6.0 1939-05-27 Batman Batmobile
81448144
2 NaN 1940-04-25 Joker
81458145
@@ -8212,7 +8212,7 @@ def notna(self) -> Self:
82128212
... )
82138213
>>> df
82148214
age born name toy
8215-
0 5.0 NaT Alfred None
8215+
0 5.0 NaT Alfred NaN
82168216
1 6.0 1939-05-27 Batman Batmobile
82178217
2 NaN 1940-04-25 Joker
82188218
@@ -10402,7 +10402,7 @@ def truncate(
1040210402
2 b
1040310403
3 c
1040410404
4 d
10405-
Name: A, dtype: object
10405+
Name: A, dtype: str
1040610406
1040710407
The index values in ``truncate`` can be datetimes or string
1040810408
dates.

pandas/core/indexes/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ def astype(self, dtype: Dtype, copy: bool = True):
12091209
--------
12101210
>>> idx = pd.Index(['a', 'b', 'c'])
12111211
>>> idx.take([2, 2, 1, 2])
1212-
Index(['c', 'c', 'b', 'c'], dtype='object')
1212+
Index(['c', 'c', 'b', 'c'], dtype='str')
12131213
"""
12141214

12151215
@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
@@ -6862,11 +6862,11 @@ def delete(
68626862
--------
68636863
>>> idx = pd.Index(["a", "b", "c"])
68646864
>>> idx.delete(1)
6865-
Index(['a', 'c'], dtype='object')
6865+
Index(['a', 'c'], dtype='str')
68666866
68676867
>>> idx = pd.Index(["a", "b", "c"])
68686868
>>> idx.delete([0, 2])
6869-
Index(['b'], dtype='object')
6869+
Index(['b'], dtype='str')
68706870
"""
68716871
values = self._values
68726872
res_values: ArrayLike
@@ -6906,7 +6906,7 @@ def insert(self, loc: int, item) -> Index:
69066906
--------
69076907
>>> idx = pd.Index(["a", "b", "c"])
69086908
>>> idx.insert(1, "x")
6909-
Index(['a', 'x', 'b', 'c'], dtype='object')
6909+
Index(['a', 'x', 'b', 'c'], dtype='str')
69106910
"""
69116911
item = lib.item_from_zerodim(item)
69126912
if is_valid_na_for_dtype(item, self.dtype) and self.dtype != object:

pandas/core/internals/api.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def make_block(
137137
if not isinstance(placement, BlockPlacement):
138138
placement = BlockPlacement(placement)
139139

140-
ndim = maybe_infer_ndim(values, placement, ndim)
140+
ndim = _maybe_infer_ndim(values, placement, ndim)
141141
if isinstance(values.dtype, (PeriodDtype, DatetimeTZDtype)):
142142
# GH#41168 ensure we can pass 1D dt64tz values
143143
# More generally, any EA dtype that isn't is_1d_only_ea_dtype
@@ -149,7 +149,7 @@ def make_block(
149149
return klass(values, ndim=ndim, placement=placement)
150150

151151

152-
def maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int:
152+
def _maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int:
153153
"""
154154
If `ndim` is not provided, infer it from placement and values.
155155
"""
@@ -163,3 +163,15 @@ def maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int
163163
else:
164164
ndim = values.ndim
165165
return ndim
166+
167+
168+
def maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int:
169+
"""
170+
If `ndim` is not provided, infer it from placement and values.
171+
"""
172+
warnings.warn(
173+
"maybe_infer_ndim is deprecated and will be removed in a future version.",
174+
DeprecationWarning,
175+
stacklevel=2,
176+
)
177+
return _maybe_infer_ndim(values, placement, ndim)

pandas/core/tools/numeric.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def to_numeric(
5555
"""
5656
Convert argument to a numeric type.
5757
58-
The default return dtype is `float64` or `int64`
58+
If the input is already of a numeric dtype, the dtype will be preserved.
59+
For non-numeric inputs, the default return dtype is `float64` or `int64`
5960
depending on the data supplied. Use the `downcast` parameter
6061
to obtain other dtypes.
6162

pandas/tests/indexing/test_iloc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import pytest
88

9+
from pandas.compat import pa_version_under16p0
910
from pandas.errors import IndexingError
1011

1112
from pandas import (
@@ -140,6 +141,9 @@ def test_is_scalar_access(self):
140141
df = ser.to_frame()
141142
assert df.iloc._is_scalar_access((1, 0))
142143

144+
@pytest.mark.skipif(
145+
pa_version_under16p0, reason="https://github.com/apache/arrow/issues/40642"
146+
)
143147
def test_iloc_exceeds_bounds(self):
144148
# GH6296
145149
# iloc should allow indexers that exceed the bounds

0 commit comments

Comments
 (0)