Skip to content

Commit a59a945

Browse files
Suggested improvements
1 parent efc846d commit a59a945

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pandas/core/indexes/base.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4040,16 +4040,17 @@ def _coerce_to_ndarray(cls, data, dtype=None):
40404040
When the data passed in is a scalar.
40414041
"""
40424042

4043-
if not isinstance(data, (np.ndarray, Index)):
4044-
if data is None or is_scalar(data):
4045-
raise cls._scalar_data_error(data)
4043+
if isinstance(data, (np.ndarray, Index)):
4044+
return data
40464045

4047-
# other iterable of some kind
4048-
if not isinstance(data, (ABCSeries, list, tuple)):
4049-
data = list(data)
4046+
if is_scalar(data):
4047+
raise cls._scalar_data_error(data)
4048+
4049+
# other iterable of some kind
4050+
if not isinstance(data, (ABCSeries, list, tuple)):
4051+
data = list(data)
40504052

4051-
data = np.asarray(data, dtype=dtype)
4052-
return data
4053+
return np.asarray(data, dtype=dtype)
40534054

40544055
def _coerce_scalar_to_index(self, item):
40554056
"""

0 commit comments

Comments
 (0)