Skip to content

Commit d44edb9

Browse files
Back to ValueError
1 parent 7963ec6 commit d44edb9

File tree

5 files changed

+4
-16
lines changed

5 files changed

+4
-16
lines changed

pandas/core/internals/construction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from pandas._libs import lib
1212
from pandas._typing import Axis, DtypeObj, Scalar
13-
from pandas.errors import MismatchedIndexValueError
1413

1514
from pandas.core.dtypes.cast import (
1615
construct_1d_arraylike_from_scalar,
@@ -745,7 +744,7 @@ def sanitize_index(data, index: Index):
745744
through a non-Index.
746745
"""
747746
if len(data) != len(index):
748-
raise MismatchedIndexValueError(
747+
raise ValueError(
749748
"Length of values "
750749
f"({len(data)}) "
751750
"does not match length of index "

pandas/errors/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,3 @@ class InvalidIndexError(Exception):
208208
209209
.. versionadded:: 1.1.0
210210
"""
211-
212-
213-
class MismatchedIndexValueError(ValueError):
214-
"""
215-
Error raised when Index and Value are mismatched
216-
"""

pandas/tests/extension/base/setitem.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.errors import MismatchedIndexValueError
5-
64
import pandas as pd
75
import pandas._testing as tm
86

@@ -250,7 +248,7 @@ def test_setitem_frame_invalid_length(self, data):
250248
rf"Length of values \({len(data[:5])}\) "
251249
rf"does not match length of index \({len(df)}\)"
252250
)
253-
with pytest.raises(MismatchedIndexValueError, match=xpr):
251+
with pytest.raises(ValueError, match=xpr):
254252
df["B"] = data[:5]
255253

256254
@pytest.mark.xfail(reason="GH#20441: setitem on extension types.")

pandas/tests/frame/indexing/test_indexing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66

77
from pandas._libs import iNaT
8-
from pandas.errors import MismatchedIndexValueError
98

109
from pandas.core.dtypes.common import is_float_dtype, is_integer
1110

@@ -166,7 +165,7 @@ def test_setitem_list(self, float_frame):
166165
rf"Length of values \({len(newcolumndata)}\) "
167166
rf"does not match length of index \({len(data)}\)"
168167
)
169-
with pytest.raises(MismatchedIndexValueError, match=msg):
168+
with pytest.raises(ValueError, match=msg):
170169
data["A"] = newcolumndata
171170

172171
df = DataFrame(0, index=range(3), columns=["tt1", "tt2"], dtype=np.int_)

pandas/tests/frame/indexing/test_setitem.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.errors import MismatchedIndexValueError
5-
64
from pandas.core.dtypes.dtypes import DatetimeTZDtype, IntervalDtype, PeriodDtype
75

86
from pandas import (
@@ -123,7 +121,7 @@ def test_setitem_wrong_length_categorical_dtype_raises(self):
123121
rf"Length of values \({len(cat)}\) "
124122
rf"does not match length of index \({len(df)}\)"
125123
)
126-
with pytest.raises(MismatchedIndexValueError, match=msg):
124+
with pytest.raises(ValueError, match=msg):
127125
df["foo"] = cat
128126

129127
def test_setitem_with_sparse_value(self):

0 commit comments

Comments
 (0)