Skip to content

Commit 7328307

Browse files
committed
Invert code to in datatype validation
1 parent cbefc9a commit 7328307

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pandas/core/frame.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -2475,20 +2475,20 @@ def _ensure_valid_index(self, value):
24752475
"""
24762476
# GH5632, make sure that we are a Series convertible
24772477
if not len(self.index):
2478-
if is_list_like(value):
2479-
try:
2480-
value = Series(value)
2481-
except:
2482-
raise ValueError('Cannot set a frame with no defined'
2483-
'index and a value that cannot be '
2484-
'converted to a Series')
2485-
2486-
self._data = self._data.reindex_axis(value.index.copy(), axis=1,
2487-
fill_value=np.nan)
2488-
else:
2478+
if not is_list_like(value):
24892479
# GH16823, Raise an error due to loss of information
24902480
raise ValueError('If using all scalar values, you must pass'
24912481
' an index')
2482+
try:
2483+
value = Series(value)
2484+
except:
2485+
raise ValueError('Cannot set a frame with no defined'
2486+
'index and a value that cannot be '
2487+
'converted to a Series')
2488+
2489+
self._data = self._data.reindex_axis(value.index.copy(), axis=1,
2490+
fill_value=np.nan)
2491+
24922492

24932493
def _set_item(self, key, value):
24942494
"""

0 commit comments

Comments
 (0)