11
11
12
12
import pandas
13
13
from pandas import (Series , DataFrame , Panel , MultiIndex , bdate_range ,
14
- date_range , Index , DatetimeIndex )
14
+ date_range , Index , DatetimeIndex , isnull )
15
15
from pandas .io .pytables import (HDFStore , get_store , Term , read_hdf ,
16
16
IncompatibilityWarning , PerformanceWarning ,
17
17
AttributeConflictWarning , DuplicateWarning ,
@@ -2404,14 +2404,11 @@ def test_frame_select(self):
2404
2404
def test_string_select (self ):
2405
2405
2406
2406
# GH 2973
2407
-
2408
- df = tm .makeTimeDataFrame ()
2409
-
2410
2407
with ensure_clean (self .path ) as store :
2411
2408
2409
+ df = tm .makeTimeDataFrame ()
2412
2410
2413
2411
# test string ==/!=
2414
-
2415
2412
df ['x' ] = 'none'
2416
2413
df .ix [2 :7 ,'x' ] = ''
2417
2414
@@ -2421,25 +2418,18 @@ def test_string_select(self):
2421
2418
expected = df [df .x == 'none' ]
2422
2419
assert_frame_equal (result ,expected )
2423
2420
2424
- print ("bogus test" )
2425
- print (df )
2426
- print (store )
2427
2421
result = store .select ('df' ,Term ('x!=none' ))
2428
- print (result )
2429
2422
expected = df [df .x != 'none' ]
2430
- print (expected )
2431
2423
assert_frame_equal (result ,expected )
2432
2424
2433
2425
df2 = df .copy ()
2434
- df2 .x [df2 .x == '' ] = np .nan
2426
+ df2 .loc [df2 .x == '' , 'x ' ] = np .nan
2435
2427
2436
- from pandas import isnull
2437
2428
store .append ('df2' ,df2 ,data_columns = ['x' ])
2438
2429
result = store .select ('df2' ,Term ('x!=none' ))
2439
2430
expected = df2 [isnull (df2 .x )]
2440
2431
assert_frame_equal (result ,expected )
2441
2432
2442
-
2443
2433
# int ==/!=
2444
2434
df ['int' ] = 1
2445
2435
df .ix [2 :7 ,'int' ] = 2
0 commit comments