Skip to content

Commit 65c6f9a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into read-csv-from-directory
2 parents b07bee1 + bd9f060 commit 65c6f9a

File tree

9 files changed

+39
-13
lines changed

9 files changed

+39
-13
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
@@ -457,6 +457,7 @@ Other Deprecations
457457
- Deprecated :meth:`.DataFrameGroupby.corrwith` (:issue:`57158`)
458458
- Deprecated :meth:`Timestamp.utcfromtimestamp`, use ``Timestamp.fromtimestamp(ts, "UTC")`` instead (:issue:`56680`)
459459
- Deprecated :meth:`Timestamp.utcnow`, use ``Timestamp.now("UTC")`` instead (:issue:`56680`)
460+
- Deprecated ``pd.core.internals.api.maybe_infer_ndim`` (:issue:`40226`)
460461
- 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`)
461462
- Deprecated allowing non-keyword arguments in :meth:`Series.to_markdown` except ``buf``. (:issue:`57280`)
462463
- 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/generic.py

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

@@ -6276,7 +6276,7 @@ def dtypes(self):
62766276
float float64
62776277
int int64
62786278
datetime datetime64[s]
6279-
string object
6279+
string str
62806280
dtype: object
62816281
"""
62826282
data = self._mgr.get_dtypes()
@@ -6838,7 +6838,7 @@ def convert_dtypes(
68386838
0 a
68396839
1 b
68406840
2 NaN
6841-
dtype: object
6841+
dtype: str
68426842
68436843
Obtain a Series with dtype ``StringDtype``.
68446844
@@ -8138,7 +8138,7 @@ def isna(self) -> Self:
81388138
... )
81398139
>>> df
81408140
age born name toy
8141-
0 5.0 NaT Alfred None
8141+
0 5.0 NaT Alfred NaN
81428142
1 6.0 1939-05-27 Batman Batmobile
81438143
2 NaN 1940-04-25 Joker
81448144
@@ -8211,7 +8211,7 @@ def notna(self) -> Self:
82118211
... )
82128212
>>> df
82138213
age born name toy
8214-
0 5.0 NaT Alfred None
8214+
0 5.0 NaT Alfred NaN
82158215
1 6.0 1939-05-27 Batman Batmobile
82168216
2 NaN 1940-04-25 Joker
82178217
@@ -10401,7 +10401,7 @@ def truncate(
1040110401
2 b
1040210402
3 c
1040310403
4 d
10404-
Name: A, dtype: object
10404+
Name: A, dtype: str
1040510405
1040610406
The index values in ``truncate`` can be datetimes or string
1040710407
dates.

pandas/core/internals/api.py

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

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

150150

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

pandas/tests/internals/test_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ def test_create_block_manager_from_blocks_deprecated():
7979
internals.create_block_manager_from_blocks
8080

8181

82+
def test_maybe_infer_ndim_deprecated():
83+
# GH#40226
84+
msg = "maybe_infer_ndim is deprecated and will be removed in a future version."
85+
arr = np.arange(5)
86+
bp = pd._libs.internals.BlockPlacement([1])
87+
with tm.assert_produces_warning(DeprecationWarning, match=msg):
88+
internals.api.maybe_infer_ndim(arr, bp, 1)
89+
90+
8291
def test_create_dataframe_from_blocks(float_frame):
8392
block = float_frame._mgr.blocks[0]
8493
index = float_frame.index.copy()

pandas/tests/io/test_gcs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
216216
{
217217
"int": [1, 3],
218218
"float": [2.0, np.nan],
219-
"str": ["t", "s"],
220219
"dt": date_range("2018-06-18", periods=2),
221220
}
222221
)

0 commit comments

Comments
 (0)