@@ -18,14 +18,14 @@ class TestDataFrameToXArray:
18
18
def df (self ):
19
19
return DataFrame (
20
20
{
21
- "a" : list ("abc " ),
22
- "b" : list (range (1 , 4 )),
23
- "c" : np .arange (3 , 6 ).astype ("u1" ),
24
- "d" : np .arange (4.0 , 7 .0 , dtype = "float64" ),
25
- "e" : [True , False , True ],
26
- "f" : Categorical (list ("abc " )),
27
- "g" : date_range ("20130101" , periods = 3 ),
28
- "h" : date_range ("20130101" , periods = 3 , tz = "US/Eastern" ),
21
+ "a" : list ("abcd " ),
22
+ "b" : list (range (1 , 5 )),
23
+ "c" : np .arange (3 , 7 ).astype ("u1" ),
24
+ "d" : np .arange (4.0 , 8 .0 , dtype = "float64" ),
25
+ "e" : [True , False , True , False ],
26
+ "f" : Categorical (list ("abcd " )),
27
+ "g" : date_range ("20130101" , periods = 4 ),
28
+ "h" : date_range ("20130101" , periods = 4 , tz = "US/Eastern" ),
29
29
}
30
30
)
31
31
@@ -37,11 +37,11 @@ def test_to_xarray_index_types(self, index_flat, df, using_infer_string):
37
37
38
38
from xarray import Dataset
39
39
40
- df .index = index [:3 ]
40
+ df .index = index [:4 ]
41
41
df .index .name = "foo"
42
42
df .columns .name = "bar"
43
43
result = df .to_xarray ()
44
- assert result .dims ["foo" ] == 3
44
+ assert result .dims ["foo" ] == 4
45
45
assert len (result .coords ) == 1
46
46
assert len (result .data_vars ) == 8
47
47
tm .assert_almost_equal (list (result .coords .keys ()), ["foo" ])
@@ -69,10 +69,10 @@ def test_to_xarray_with_multiindex(self, df, using_infer_string):
69
69
from xarray import Dataset
70
70
71
71
# MultiIndex
72
- df .index = MultiIndex .from_product ([["a" ], range (3 )], names = ["one" , "two" ])
72
+ df .index = MultiIndex .from_product ([["a" ], range (4 )], names = ["one" , "two" ])
73
73
result = df .to_xarray ()
74
74
assert result .dims ["one" ] == 1
75
- assert result .dims ["two" ] == 3
75
+ assert result .dims ["two" ] == 4
76
76
assert len (result .coords ) == 2
77
77
assert len (result .data_vars ) == 8
78
78
tm .assert_almost_equal (list (result .coords .keys ()), ["one" , "two" ])
0 commit comments