What does the “at” (@) symbol do in Python?

前端 未结 12 981
萌比男神i
萌比男神i 2020-11-22 01:57

I\'m looking at some Python code which used the @ symbol, but I have no idea what it does. I also do not know what to search for as searching Python docs or Goo

12条回答
  •  故里飘歌
    2020-11-22 02:27

    @ symbol is also used to access variables inside a plydata / pandas dataframe query, pandas.DataFrame.query. Example:

    df = pandas.DataFrame({'foo': [1,2,15,17]})
    y = 10
    df >> query('foo > @y') # plydata
    df.query('foo > @y') # pandas
    

提交回复
热议问题