pandas eval及query
import pandas as pd data = pd.DataFrame({ "Student": ["A", "B", "C", "D"], "Physics": [89,34,23,56], "Chemistry": [34,56,98,56], "Math": [34,94,50,59], 'Name':["LI","Zhang","Wang","Xiao"] }) pd.eval("data.Physics+data.Chemistry+data.Math") data.eval("total=Physics+Chemistry+Math").query('Math>50') data.eval('total2=Student',engine='python') data.eval('total2=Student+Name',engine='python') # 'numexpr': This default engine evaluates pandas objects using # numexpr for large speed ups in complex expressions with large frames. # 'python': Performs operations as if you had eval’d in top # level python. This engine is generally not that useful. (data.eval('total=sqrt(Math)') .query('Chemistry>34')) data=pd.read_excel(r"C:\Users\xuefe\Desk