File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -3392,7 +3392,7 @@ def _ensure_valid_index(self, value):
33923392 passed value.
33933393 """
33943394 # GH5632, make sure that we are a Series convertible
3395- if not len (self .index ) and len (value ) and is_list_like (value ):
3395+ if not len (self .index ) and is_list_like (value ) and len (value ):
33963396 try :
33973397 value = Series (value )
33983398 except (ValueError , NotImplementedError , TypeError ):
Original file line number Diff line number Diff line change @@ -627,6 +627,11 @@ def test_index_type_coercion(self):
627627 idxr (s2 )['0' ] = 0
628628 assert s2 .index .is_object ()
629629
630+ def test_empty_index_for_empty_dataframe (self ):
631+ empty_df = pd .DataFrame (columns = ['A' ])
632+ df_with_empty_value = pd .DataFrame (columns = ['A' ], data = [])
633+ assert df_with_empty_value .index .dtype == empty_df .index .dtype
634+
630635
631636class TestMisc (Base ):
632637
You can’t perform that action at this time.
0 commit comments