@@ -342,7 +342,7 @@ def test_repr(self, setup_path):
342
342
df ["timestamp2" ] = Timestamp ("20010103" )
343
343
df ["datetime1" ] = datetime .datetime (2001 , 1 , 2 , 0 , 0 )
344
344
df ["datetime2" ] = datetime .datetime (2001 , 1 , 3 , 0 , 0 )
345
- df .loc [3 :6 , ["obj1" ]] = np .nan
345
+ df .loc [df . index [ 3 :6 ] , ["obj1" ]] = np .nan
346
346
df = df ._consolidate ()._convert (datetime = True )
347
347
348
348
with catch_warnings (record = True ):
@@ -846,7 +846,7 @@ def test_put_mixed_type(self, setup_path):
846
846
df ["timestamp2" ] = Timestamp ("20010103" )
847
847
df ["datetime1" ] = datetime .datetime (2001 , 1 , 2 , 0 , 0 )
848
848
df ["datetime2" ] = datetime .datetime (2001 , 1 , 3 , 0 , 0 )
849
- df .loc [3 :6 , ["obj1" ]] = np .nan
849
+ df .loc [df . index [ 3 :6 ] , ["obj1" ]] = np .nan
850
850
df = df ._consolidate ()._convert (datetime = True )
851
851
852
852
with ensure_clean_store (setup_path ) as store :
@@ -1372,11 +1372,11 @@ def check_col(key, name, size):
1372
1372
_maybe_remove (store , "df" )
1373
1373
df = tm .makeTimeDataFrame ()
1374
1374
df ["string" ] = "foo"
1375
- df .loc [1 :4 , "string" ] = np .nan
1375
+ df .loc [df . index [ 1 :4 ] , "string" ] = np .nan
1376
1376
df ["string2" ] = "bar"
1377
- df .loc [4 :8 , "string2" ] = np .nan
1377
+ df .loc [df . index [ 4 :8 ] , "string2" ] = np .nan
1378
1378
df ["string3" ] = "bah"
1379
- df .loc [1 : , "string3" ] = np .nan
1379
+ df .loc [df . index [ 1 :] , "string3" ] = np .nan
1380
1380
store .append ("df" , df )
1381
1381
result = store .select ("df" )
1382
1382
tm .assert_frame_equal (result , df )
@@ -1492,8 +1492,8 @@ def test_append_with_data_columns(self, setup_path):
1492
1492
# data column selection with a string data_column
1493
1493
df_new = df .copy ()
1494
1494
df_new ["string" ] = "foo"
1495
- df_new .loc [1 :4 , "string" ] = np .nan
1496
- df_new .loc [5 :6 , "string" ] = "bar"
1495
+ df_new .loc [df_new . index [ 1 :4 ] , "string" ] = np .nan
1496
+ df_new .loc [df_new . index [ 5 :6 ] , "string" ] = "bar"
1497
1497
_maybe_remove (store , "df" )
1498
1498
store .append ("df" , df_new , data_columns = ["string" ])
1499
1499
result = store .select ("df" , "string='foo'" )
@@ -1574,12 +1574,12 @@ def check_col(key, name, size):
1574
1574
# doc example
1575
1575
df_dc = df .copy ()
1576
1576
df_dc ["string" ] = "foo"
1577
- df_dc .loc [4 :6 , "string" ] = np .nan
1578
- df_dc .loc [7 :9 , "string" ] = "bar"
1577
+ df_dc .loc [df_dc . index [ 4 :6 ] , "string" ] = np .nan
1578
+ df_dc .loc [df_dc . index [ 7 :9 ] , "string" ] = "bar"
1579
1579
df_dc ["string2" ] = "cool"
1580
1580
df_dc ["datetime" ] = Timestamp ("20010102" )
1581
1581
df_dc = df_dc ._convert (datetime = True )
1582
- df_dc .loc [3 :5 , ["A" , "B" , "datetime" ]] = np .nan
1582
+ df_dc .loc [df_dc . index [ 3 :5 ] , ["A" , "B" , "datetime" ]] = np .nan
1583
1583
1584
1584
_maybe_remove (store , "df_dc" )
1585
1585
store .append (
@@ -1602,8 +1602,8 @@ def check_col(key, name, size):
1602
1602
np .random .randn (8 , 3 ), index = index , columns = ["A" , "B" , "C" ]
1603
1603
)
1604
1604
df_dc ["string" ] = "foo"
1605
- df_dc .loc [4 :6 , "string" ] = np .nan
1606
- df_dc .loc [7 :9 , "string" ] = "bar"
1605
+ df_dc .loc [df_dc . index [ 4 :6 ] , "string" ] = np .nan
1606
+ df_dc .loc [df_dc . index [ 7 :9 ] , "string" ] = "bar"
1607
1607
df_dc .loc [:, ["B" , "C" ]] = df_dc .loc [:, ["B" , "C" ]].abs ()
1608
1608
df_dc ["string2" ] = "cool"
1609
1609
@@ -2024,7 +2024,7 @@ def test_table_mixed_dtypes(self, setup_path):
2024
2024
df ["timestamp2" ] = Timestamp ("20010103" )
2025
2025
df ["datetime1" ] = datetime .datetime (2001 , 1 , 2 , 0 , 0 )
2026
2026
df ["datetime2" ] = datetime .datetime (2001 , 1 , 3 , 0 , 0 )
2027
- df .loc [3 :6 , ["obj1" ]] = np .nan
2027
+ df .loc [df . index [ 3 :6 ] , ["obj1" ]] = np .nan
2028
2028
df = df ._consolidate ()._convert (datetime = True )
2029
2029
2030
2030
with ensure_clean_store (setup_path ) as store :
@@ -2200,7 +2200,7 @@ def test_invalid_terms(self, setup_path):
2200
2200
2201
2201
df = tm .makeTimeDataFrame ()
2202
2202
df ["string" ] = "foo"
2203
- df .loc [0 :4 , "string" ] = "bar"
2203
+ df .loc [df . index [ 0 :4 ] , "string" ] = "bar"
2204
2204
2205
2205
store .put ("df" , df , format = "table" )
2206
2206
@@ -3343,7 +3343,7 @@ def test_string_select(self, setup_path):
3343
3343
3344
3344
# test string ==/!=
3345
3345
df ["x" ] = "none"
3346
- df .loc [2 :7 , "x" ] = ""
3346
+ df .loc [df . index [ 2 :7 ] , "x" ] = ""
3347
3347
3348
3348
store .append ("df" , df , data_columns = ["x" ])
3349
3349
@@ -3365,7 +3365,7 @@ def test_string_select(self, setup_path):
3365
3365
3366
3366
# int ==/!=
3367
3367
df ["int" ] = 1
3368
- df .loc [2 :7 , "int" ] = 2
3368
+ df .loc [df . index [ 2 :7 ] , "int" ] = 2
3369
3369
3370
3370
store .append ("df3" , df , data_columns = ["int" ])
3371
3371
@@ -3419,7 +3419,7 @@ def test_read_column(self, setup_path):
3419
3419
# a data column with NaNs, result excludes the NaNs
3420
3420
df3 = df .copy ()
3421
3421
df3 ["string" ] = "foo"
3422
- df3 .loc [4 :6 , "string" ] = np .nan
3422
+ df3 .loc [df3 . index [ 4 :6 ] , "string" ] = np .nan
3423
3423
store .append ("df3" , df3 , data_columns = ["string" ])
3424
3424
result = store .select_column ("df3" , "string" )
3425
3425
tm .assert_almost_equal (result .values , df3 ["string" ].values )
0 commit comments