File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -2474,16 +2474,21 @@ def _ensure_valid_index(self, value):
2474
2474
passed value
2475
2475
"""
2476
2476
# GH5632, make sure that we are a Series convertible
2477
- if not len (self .index ) and is_list_like (value ):
2478
- try :
2479
- value = Series (value )
2480
- except :
2481
- raise ValueError ('Cannot set a frame with no defined index '
2482
- 'and a value that cannot be converted to a '
2483
- 'Series' )
2484
-
2485
- self ._data = self ._data .reindex_axis (value .index .copy (), axis = 1 ,
2486
- fill_value = np .nan )
2477
+ 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 :
2489
+ # GH16823, Raise an error due to loss of information
2490
+ raise ValueError ('If using all scalar values, you must pass'
2491
+ ' an index' )
2487
2492
2488
2493
def _set_item (self , key , value ):
2489
2494
"""
You can’t perform that action at this time.
0 commit comments