@@ -667,7 +667,7 @@ def test_unary_in_array(self):
667
667
@pytest .mark .parametrize ("dtype" , [np .float32 , np .float64 ])
668
668
def test_float_comparison_bin_op (self , dtype ):
669
669
# GH 16363
670
- df = pd . DataFrame ({"x" : np .array ([0 ], dtype = dtype )})
670
+ df = DataFrame ({"x" : np .array ([0 ], dtype = dtype )})
671
671
res = df .eval ("x < -0.1" )
672
672
assert res .values == np .array ([False ])
673
673
@@ -734,7 +734,7 @@ def test_float_truncation(self):
734
734
expected = np .float64 (exp )
735
735
assert result == expected
736
736
737
- df = pd . DataFrame ({"A" : [1000000000.0009 , 1000000000.0011 , 1000000000.0015 ]})
737
+ df = DataFrame ({"A" : [1000000000.0009 , 1000000000.0011 , 1000000000.0015 ]})
738
738
cutoff = 1000000000.0006
739
739
result = df .query (f"A < { cutoff :.4f} " )
740
740
assert result .empty
@@ -751,12 +751,12 @@ def test_float_truncation(self):
751
751
752
752
def test_disallow_python_keywords (self ):
753
753
# GH 18221
754
- df = pd . DataFrame ([[0 , 0 , 0 ]], columns = ["foo" , "bar" , "class" ])
754
+ df = DataFrame ([[0 , 0 , 0 ]], columns = ["foo" , "bar" , "class" ])
755
755
msg = "Python keyword not valid identifier in numexpr query"
756
756
with pytest .raises (SyntaxError , match = msg ):
757
757
df .query ("class == 0" )
758
758
759
- df = pd . DataFrame ()
759
+ df = DataFrame ()
760
760
df .index .name = "lambda"
761
761
with pytest .raises (SyntaxError , match = msg ):
762
762
df .query ("lambda == 0" )
@@ -1366,7 +1366,7 @@ def assignment_not_inplace(self):
1366
1366
1367
1367
def test_multi_line_expression (self ):
1368
1368
# GH 11149
1369
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1369
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1370
1370
expected = df .copy ()
1371
1371
1372
1372
expected ["c" ] = expected ["a" ] + expected ["b" ]
@@ -1403,7 +1403,7 @@ def test_multi_line_expression(self):
1403
1403
1404
1404
def test_multi_line_expression_not_inplace (self ):
1405
1405
# GH 11149
1406
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1406
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1407
1407
expected = df .copy ()
1408
1408
1409
1409
expected ["c" ] = expected ["a" ] + expected ["b" ]
@@ -1428,7 +1428,7 @@ def test_multi_line_expression_not_inplace(self):
1428
1428
1429
1429
def test_multi_line_expression_local_variable (self ):
1430
1430
# GH 15342
1431
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1431
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1432
1432
expected = df .copy ()
1433
1433
1434
1434
local_var = 7
@@ -1446,7 +1446,7 @@ def test_multi_line_expression_local_variable(self):
1446
1446
1447
1447
def test_multi_line_expression_callable_local_variable (self ):
1448
1448
# 26426
1449
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1449
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1450
1450
1451
1451
def local_func (a , b ):
1452
1452
return b
@@ -1466,7 +1466,7 @@ def local_func(a, b):
1466
1466
1467
1467
def test_multi_line_expression_callable_local_variable_with_kwargs (self ):
1468
1468
# 26426
1469
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1469
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1470
1470
1471
1471
def local_func (a , b ):
1472
1472
return b
@@ -1486,7 +1486,7 @@ def local_func(a, b):
1486
1486
1487
1487
def test_assignment_in_query (self ):
1488
1488
# GH 8664
1489
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1489
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1490
1490
df_orig = df .copy ()
1491
1491
msg = "cannot assign without a target object"
1492
1492
with pytest .raises (ValueError , match = msg ):
@@ -1495,7 +1495,7 @@ def test_assignment_in_query(self):
1495
1495
1496
1496
def test_query_inplace (self ):
1497
1497
# see gh-11149
1498
- df = pd . DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1498
+ df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
1499
1499
expected = df .copy ()
1500
1500
expected = expected [expected ["a" ] == 2 ]
1501
1501
df .query ("a == 2" , inplace = True )
@@ -2052,7 +2052,7 @@ def test_truediv_deprecated(engine, parser):
2052
2052
2053
2053
2054
2054
def test_negate_lt_eq_le (engine , parser ):
2055
- df = pd . DataFrame ([[0 , 10 ], [1 , 20 ]], columns = ["cat" , "count" ])
2055
+ df = DataFrame ([[0 , 10 ], [1 , 20 ]], columns = ["cat" , "count" ])
2056
2056
expected = df [~ (df .cat > 0 )]
2057
2057
2058
2058
result = df .query ("~(cat > 0)" , engine = engine , parser = parser )
0 commit comments