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

`str(x)` in define #14

Closed beau-mind closed 6 years ago

beau-mind commented 6 years ago
df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], 't': [1, 2, 3, 4, 5, 6]})
df >> define(('z','str(x)'))

produces wrong output. I can do this using df['x'].astype(str) in Pandas, but will this be supported by Plotnine?

has2k1 commented 6 years ago

It the correct output, although not what the user intends.

These are equivalent

df >> define(('z','str(x)'))
df['z'] = str(df['x']))

Try

df >> define(z='x.astype(str)')