Skip to content

Commit adf847a

Browse files
update whatsnew
1 parent af6ccf6 commit adf847a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

doc/source/whatsnew/v0.25.0.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ Performance Improvements
227227

228228
Bug Fixes
229229
~~~~~~~~~
230-
230+
- Bug in :func:`to_datetime` which would raise an (incorrect) ``ValueError`` when called with a date far into the future and the ``format`` argument specified instead of raising ``OutOfBoundsDatetime`` (:issue:`23830`)
231+
- Bug in `SparseDataFrame` when adding a column in which the length of values does not match length of index, ``AssertionError`` is raised instead of raising ``ValueError`` (:issue:`25484`)
231232

232233
Categorical
233234
^^^^^^^^^^^

pandas/core/sparse/frame.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ def sp_maker(x, index=None):
432432

433433
elif isinstance(value, SparseArray):
434434
if len(value) != len(self.index):
435-
raise AssertionError('Length of values does not match '
436-
'length of index')
435+
raise ValueError('Length of values does not match '
436+
'length of index')
437437
clean = value
438438

439439
elif hasattr(value, '__iter__'):
@@ -443,8 +443,8 @@ def sp_maker(x, index=None):
443443
clean = sp_maker(clean)
444444
else:
445445
if len(value) != len(self.index):
446-
raise AssertionError('Length of values does not match '
447-
'length of index')
446+
raise ValueError('Length of values does not match '
447+
'length of index')
448448
clean = sp_maker(value)
449449

450450
# Scalar

pandas/tests/sparse/frame/test_frame.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,9 @@ def _check_frame(frame, orig):
568568
assert len(frame['I'].sp_values) == N // 2
569569

570570
# insert ndarray wrong size
571-
msg = "Length of values does not match length of index"
572-
with pytest.raises(AssertionError, match=msg):
571+
# GH 25484
572+
msg = 'Length of values does not match length of index'
573+
with pytest.raises(ValueError, match=msg):
573574
frame['foo'] = np.random.randn(N - 1)
574575

575576
# scalar value

0 commit comments

Comments
 (0)