has2k1 / plydata

A grammar for data manipulation in Python
https://plydata.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
276 stars 11 forks source link

define throws error when accessing column named 'n' #6

Closed neo-anderson closed 7 years ago

neo-anderson commented 7 years ago
from plydata import (define, rename, query)
df = pd.DataFrame({'n': [1,2,3]})
df >> define(y = 'n+1')

throws TypeError: unsupported operand type(s) for +: 'function' and 'int' query function has no issues with it though.

from plydata import (define, rename, query)
df = pd.DataFrame({'n': [1,2,3]})
df >> query('n>1')
has2k1 commented 7 years ago

n is a special function. To prevent surprises, it may be worth it to make an exception in cases where the dataframe has a column named n.