3
3
import numpy as np
4
4
import pytest
5
5
6
- from pandas import DataFrame , Panel , date_range
6
+ from pandas import Panel , date_range
7
7
from pandas .util import testing as tm
8
8
9
9
@@ -31,30 +31,6 @@ def test_iloc_getitem_panel(self):
31
31
expected = p .loc ['B' , 'b' , 'two' ]
32
32
assert result == expected
33
33
34
- # slice
35
- result = p .iloc [1 :3 ]
36
- expected = p .loc [['B' , 'C' ]]
37
- tm .assert_panel_equal (result , expected )
38
-
39
- result = p .iloc [:, 0 :2 ]
40
- expected = p .loc [:, ['a' , 'b' ]]
41
- tm .assert_panel_equal (result , expected )
42
-
43
- # list of integers
44
- result = p .iloc [[0 , 2 ]]
45
- expected = p .loc [['A' , 'C' ]]
46
- tm .assert_panel_equal (result , expected )
47
-
48
- # neg indices
49
- result = p .iloc [[- 1 , 1 ], [- 1 , 1 ]]
50
- expected = p .loc [['D' , 'B' ], ['c' , 'b' ]]
51
- tm .assert_panel_equal (result , expected )
52
-
53
- # dups indices
54
- result = p .iloc [[- 1 , - 1 , 1 ], [- 1 , 1 ]]
55
- expected = p .loc [['D' , 'D' , 'B' ], ['c' , 'b' ]]
56
- tm .assert_panel_equal (result , expected )
57
-
58
34
# combined
59
35
result = p .iloc [0 , [True , True ], [0 , 1 ]]
60
36
expected = p .loc ['A' , ['a' , 'b' ], ['one' , 'two' ]]
@@ -110,18 +86,6 @@ def test_iloc_panel_issue(self):
110
86
def test_panel_getitem (self ):
111
87
112
88
with catch_warnings (record = True ):
113
- # GH4016, date selection returns a frame when a partial string
114
- # selection
115
- ind = date_range (start = "2000" , freq = "D" , periods = 1000 )
116
- df = DataFrame (
117
- np .random .randn (
118
- len (ind ), 5 ), index = ind , columns = list ('ABCDE' ))
119
- panel = Panel ({'frame_' + c : df for c in list ('ABC' )})
120
-
121
- test2 = panel .loc [:, "2002" :"2002-12-31" ]
122
- test1 = panel .loc [:, "2002" ]
123
- tm .assert_panel_equal (test1 , test2 )
124
-
125
89
# with an object-like
126
90
# GH 9140
127
91
class TestObject (object ):
@@ -138,55 +102,3 @@ def __str__(self):
138
102
expected = p .iloc [0 ]
139
103
result = p [obj ]
140
104
tm .assert_frame_equal (result , expected )
141
-
142
- def test_panel_setitem (self ):
143
-
144
- with catch_warnings (record = True ):
145
- # GH 7763
146
- # loc and setitem have setting differences
147
- np .random .seed (0 )
148
- index = range (3 )
149
- columns = list ('abc' )
150
-
151
- panel = Panel ({'A' : DataFrame (np .random .randn (3 , 3 ),
152
- index = index , columns = columns ),
153
- 'B' : DataFrame (np .random .randn (3 , 3 ),
154
- index = index , columns = columns ),
155
- 'C' : DataFrame (np .random .randn (3 , 3 ),
156
- index = index , columns = columns )})
157
-
158
- replace = DataFrame (np .eye (3 , 3 ), index = range (3 ), columns = columns )
159
- expected = Panel ({'A' : replace , 'B' : replace , 'C' : replace })
160
-
161
- p = panel .copy ()
162
- for idx in list ('ABC' ):
163
- p [idx ] = replace
164
- tm .assert_panel_equal (p , expected )
165
-
166
- p = panel .copy ()
167
- for idx in list ('ABC' ):
168
- p .loc [idx , :, :] = replace
169
- tm .assert_panel_equal (p , expected )
170
-
171
- def test_panel_assignment (self ):
172
-
173
- with catch_warnings (record = True ):
174
- # GH3777
175
- wp = Panel (np .random .randn (2 , 5 , 4 ), items = ['Item1' , 'Item2' ],
176
- major_axis = date_range ('1/1/2000' , periods = 5 ),
177
- minor_axis = ['A' , 'B' , 'C' , 'D' ])
178
- wp2 = Panel (np .random .randn (2 , 5 , 4 ), items = ['Item1' , 'Item2' ],
179
- major_axis = date_range ('1/1/2000' , periods = 5 ),
180
- minor_axis = ['A' , 'B' , 'C' , 'D' ])
181
-
182
- # TODO: unused?
183
- # expected = wp.loc[['Item1', 'Item2'], :, ['A', 'B']]
184
-
185
- with pytest .raises (NotImplementedError ):
186
- wp .loc [['Item1' , 'Item2' ], :, ['A' , 'B' ]] = wp2 .loc [
187
- ['Item1' , 'Item2' ], :, ['A' , 'B' ]]
188
-
189
- # to_assign = wp2.loc[['Item1', 'Item2'], :, ['A', 'B']]
190
- # wp.loc[['Item1', 'Item2'], :, ['A', 'B']] = to_assign
191
- # result = wp.loc[['Item1', 'Item2'], :, ['A', 'B']]
192
- # tm.assert_panel_equal(result,expected)
0 commit comments