robdmc / pandashells

:panda_face: Bringing the python data stack to the shell prompt
Other
788 stars 26 forks source link

group and filter results with exclude #27

Closed jungle-boogie closed 9 years ago

jungle-boogie commented 9 years ago

Hello,

Really liking the power of pandashell!

sample data here: https://gist.github.com/jungle-boogie/fbb3b0f617c01379be77

cat data.csv | p.df 'df[df.state=="Settled"]' \ 'df.groupby(by=["date","type"]).amount.mean()' -o table index

How do I exclude records like Credit Card Return & Debit Card Return?

Or even in your example p.example_data -d tips | p.df 'df[df.sex=="Female"]' 'df[df.smoker=="Yes"]' -o table

How do you exclude all records of dinner?

Thanks!

robdmc commented 9 years ago

I would encourage you to spend some time with the Pandas documentation, particularly the tutorial http://pandas.pydata.org/pandas-docs/version/0.16.2/tutorials.html It should give you a good feel for the syntax you should be using with Pandashells, and also provide a better grasp of what is and is not possible with Pandashells.

In response to your specific question, however. p.example_data -d tips | p.df 'df[df.sex=="Female"]' 'df[df.smoker=="Yes"]' 'df[df.time !="Dinner"]' -o table

jungle-boogie commented 9 years ago

I would encourage you to spend some time with the Pandas documentation, particularly the tutorial http://pandas.pydata.org/pandas-docs/version/0.16.2/tutorials.html

Thank you. This will be extremely helpful as I was only aware of p.df -h page.

robdmc commented 9 years ago

Pandashells is great for quick and dirty work. If you are doing more than that, and are spending time building up a real analysis, I really recommend using IPython Notebook.

See, for example. https://github.com/jvns/pandas-cookbook/tree/master/cookbook

jungle-boogie commented 9 years ago

See, for example. https://github.com/jvns/pandas-cookbook/tree/master/cookbook

I think this may even be simpler: https://harelba.github.io/q/

I'll check out pandas, too.