File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2872,6 +2872,15 @@ def test_to_and_from_series(self):
2872
2872
expected_da ,
2873
2873
DataArray .from_series (actual ).drop (['x' , 'y' ]))
2874
2874
2875
+ def test_to_and_from_empty_series (self ):
2876
+ # GH697
2877
+ expected = pd .Series ([])
2878
+ da = DataArray .from_series (expected )
2879
+ assert len (da ) == 0
2880
+ actual = da .to_series ()
2881
+ assert len (actual ) == 0
2882
+ assert expected .equals (actual )
2883
+
2875
2884
def test_series_categorical_index (self ):
2876
2885
# regression test for GH700
2877
2886
if not hasattr (pd , 'CategoricalIndex' ):
Original file line number Diff line number Diff line change @@ -2980,6 +2980,15 @@ def test_to_and_from_dataframe(self):
2980
2980
expected = pd .DataFrame ([[]], index = idx )
2981
2981
assert expected .equals (actual ), (expected , actual )
2982
2982
2983
+ def test_to_and_from_empty_dataframe (self ):
2984
+ # GH697
2985
+ expected = pd .DataFrame ({'foo' : []})
2986
+ ds = Dataset .from_dataframe (expected )
2987
+ assert len (ds ['foo' ]) == 0
2988
+ actual = ds .to_dataframe ()
2989
+ assert len (actual ) == 0
2990
+ assert expected .equals (actual )
2991
+
2983
2992
def test_from_dataframe_non_unique_columns (self ):
2984
2993
# regression test for GH449
2985
2994
df = pd .DataFrame (np .zeros ((2 , 2 )))
You can’t perform that action at this time.
0 commit comments