Giter Site home page Giter Site logo

Proper Factor Function about ggpy HOT 8 CLOSED

yhat avatar yhat commented on July 19, 2024
Proper Factor Function

from ggpy.

Comments (8)

glamp avatar glamp commented on July 19, 2024

Yeah I was thinking of writing a library with R-Like functions for python. Purely functional style with thinks like factor, table, etc.

We could throw it in ggplot or make it a separate library. I'd probably go with the later.

Thoughts?

On Oct 17, 2013, at 9:09 PM, Stefan Eng [email protected] wrote:

R has the 'factor' function: http://stat.ethz.ch/R-manual/R-devel/library/base/html/factor.html

Is there interest in implementing this so we can write:

p = ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot()
instead of:

p = ggplot(mtcars, aes('factor(cyl)', mpg))
p + geom_boxplot()

Reply to this email directly or view it on GitHub.

from ggpy.

stefaneng avatar stefaneng commented on July 19, 2024

Yeah that would be a pretty cool idea. Separate library would probably be better. I wouldn't mind working on that at some point.

from ggpy.

glamp avatar glamp commented on July 19, 2024

cool. i'll put something together.

On Thu, Oct 17, 2013 at 9:59 PM, Stefan Eng [email protected]:

Yeah that would be a pretty cool idea. Separate library would probably be
better. I wouldn't mind working on that at some point.


Reply to this email directly or view it on GitHubhttps://github.com//issues/40#issuecomment-26567422
.

from ggpy.

pzwang avatar pzwang commented on July 19, 2024

Nifty. Would be cool to see if we can compile those expression graphs directly with Numba to Blaze kernels.

from ggpy.

jankatins avatar jankatins commented on July 19, 2024

I don't think python allows this, as for p = ggplot(mtcars, aes(factor(cyl), mpg)) "cyl" needs to be available as a variable [edit] when aes(...) is called[/edit](as well as mpg! Both are columns in the dataframe: mtcars["mpg"]) . R has some lazy evaluation rules, which makes this possible but I think python won't allow for it.

[edit] As far as I understand R lazy evaluation rules, the function call gets the code passed in and aes can then evaluate the code against the dataset, but in the above example in python aes gets the result of factor(cyl) that would mean that both factor and cyl must be available in that context. [/edit]

I think there are already functions in either pandas or patsy (the library which implements R like formulas for statsmodels) to convert a pandas.Series to factors (see pandas.Categorical). But I'm not sure how that could be used in this case unless you want to NOT pass in a dataframe but the series directly.

What could make sense is using pandas.Categorial internaly in https://github.com/yhat/ggplot/blob/master/ggplot/ggplot.py#L70 or using patsy formulas where ggplot accepts R formulas.

from ggpy.

jankatins avatar jankatins commented on July 19, 2024

Also see #188

from ggpy.

jankatins avatar jankatins commented on July 19, 2024

Proper factor() would need updates in pandas. see pandas-dev/pandas#5313

from ggpy.

glamp avatar glamp commented on July 19, 2024

fixed in 0.9.3

from ggpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.