Code snippet 1
import pandas as pd
df = pd.read_csv("filename.txt", sep='\t', header = 0, names = ['E', 'S', 'D'])
Result = df.query(df.E.head(**n=100**) == 0)
Code Snippet 1 works as expected and returns a dataframe with df.E value equal to 0.
But,
Code Snippet 2
import pandas as pd
df = pd.read_csv("filename.txt", sep='\t', header = 0, names = ['E', 'S', 'D'])
Result = df.query(df.E.head(**n=101**) == 0)
Code Snippet 2 does not work and throws error as
"SyntaxError: ('invalid syntax', ('<unknown>', 1, 602, '[True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,... ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,True ,...]\n'))"
Please note that only change between 2 sets of code is n=100 and n=101.
The error is still present with .head(n=101) removed. Have tried for many values greater than 100, throws same error.
querythat way? You're supposed to pass a string, not an actual condition. See the documentation.**there? Is that a typo?