Skip to content

Commit

Permalink
Invert code to in datatype validation
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbato committed Jul 16, 2017
1 parent cbefc9a commit 7328307
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2475,20 +2475,20 @@ def _ensure_valid_index(self, value):
"""
# GH5632, make sure that we are a Series convertible
if not len(self.index):
if is_list_like(value):
try:
value = Series(value)
except:
raise ValueError('Cannot set a frame with no defined'
'index and a value that cannot be '
'converted to a Series')

self._data = self._data.reindex_axis(value.index.copy(), axis=1,
fill_value=np.nan)
else:
if not is_list_like(value):
# GH16823, Raise an error due to loss of information
raise ValueError('If using all scalar values, you must pass'
' an index')
try:
value = Series(value)
except:
raise ValueError('Cannot set a frame with no defined'
'index and a value that cannot be '
'converted to a Series')

self._data = self._data.reindex_axis(value.index.copy(), axis=1,
fill_value=np.nan)


def _set_item(self, key, value):
"""
Expand Down

0 comments on commit 7328307

Please sign in to comment.