has2k1 / plydata

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

Add clarifying example to query documentation #29

Closed jwhendy closed 2 years ago

jwhendy commented 2 years ago

Greetings,

Awesome to find this package. This is probably obvious in hindsight, or to those more experienced, but it took me a couple tries to get query() working with a string. I wondered if the docs could be updated with something like this? [Edit: my problem was not quoting the "string_to_match".]

df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5],
                   'y': [0, 0, 1, 1, 2, 3],
                   'z': ['a', 'b', 'c', 'c', 'd', 'e']})
df >> query('z == "c"')

I noticed that the link to pandas query also doesn't show examples of matching to strings.

If you're interested in this, I can updated the example df to include this new column and update the other example output accordingly?

I also might misunderstand how one should do the above. This is admittedly my first time using the package. Happy to help with a PR if you think this is a helpful suggestion.

has2k1 commented 2 years ago

Fixed in master.