@@ -248,16 +248,22 @@ def test_getitem_boolean_casting(self):
248
248
df = self .tsframe .copy ()
249
249
df ['E' ] = 1
250
250
df ['E' ] = df ['E' ].astype ('int32' )
251
+ df ['E1' ] = df ['E' ].copy ()
251
252
df ['F' ] = 1
252
253
df ['F' ] = df ['F' ].astype ('int64' )
254
+ df ['F1' ] = df ['F' ].copy ()
255
+
253
256
casted = df [df > 0 ]
254
257
result = casted .get_dtype_counts ()
255
- expected = Series ({'float64' : 4 , 'int32' : 1 , 'int64' : 1 })
256
-
257
- ### when we always cast here's the result ###
258
- #expected = Series({'float64': 6 })
258
+ expected = Series ({'float64' : 4 , 'int32' : 2 , 'int64' : 2 })
259
259
assert_series_equal (result , expected )
260
260
261
+ # int block splitting
262
+ df .ix [1 :3 ,['E1' ,'F1' ]] = 0
263
+ casted = df [df > 0 ]
264
+ result = casted .get_dtype_counts ()
265
+ expected = Series ({'float64' : 6 , 'int32' : 1 , 'int64' : 1 })
266
+ assert_series_equal (result , expected )
261
267
262
268
def test_getitem_boolean_list (self ):
263
269
df = DataFrame (np .arange (12 ).reshape (3 , 4 ))
@@ -6031,6 +6037,7 @@ def _check_align(df, cond, other, check_dtypes = True):
6031
6037
6032
6038
# dtypes
6033
6039
# can't check dtype when other is an ndarray
6040
+
6034
6041
if check_dtypes and not isinstance (other ,np .ndarray ):
6035
6042
self .assert_ ((rs .dtypes == df .dtypes ).all () == True )
6036
6043
@@ -6066,13 +6073,15 @@ def _check_set(df, cond, check_dtypes = True):
6066
6073
dfi = df .copy ()
6067
6074
econd = cond .reindex_like (df ).fillna (True )
6068
6075
expected = dfi .mask (~ econd )
6076
+
6077
+ #import pdb; pdb.set_trace()
6069
6078
dfi .where (cond , np .nan , inplace = True )
6070
6079
assert_frame_equal (dfi , expected )
6071
6080
6072
6081
# dtypes (and confirm upcasts)x
6073
6082
if check_dtypes :
6074
6083
for k , v in df .dtypes .iteritems ():
6075
- if issubclass (v .type ,np .integer ):
6084
+ if issubclass (v .type ,np .integer ) and not cond [ k ]. all () :
6076
6085
v = np .dtype ('float64' )
6077
6086
self .assert_ (dfi [k ].dtype == v )
6078
6087
0 commit comments