Comments (8)
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.
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.
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.
Nifty. Would be cool to see if we can compile those expression graphs directly with Numba to Blaze kernels.
from ggpy.
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.
Also see #188
from ggpy.
Proper factor()
would need updates in pandas. see pandas-dev/pandas#5313
from ggpy.
fixed in 0.9.3
from ggpy.
Related Issues (20)
- Issue with scale_color_brewer HOT 1
- [Feature Request]: Plot directly onto a matplotlib axis HOT 1
- the numbers squeeze on the x-axis or y-axis
- Wrong code
- Is this project dead? HOT 16
- "metaclass conflict" error when using ggplot 0.6.8 with six 1.10.0+
- Import does not work with pandas 0.23.4
- unable to import in jupyter notebook HOT 5
- Warning received when using color aesthetic with geom_point
- Import issue in jupyter notebook
- AttributeError: module 'pandas' has no attribute 'tslib' HOT 35
- Can't facet on variable with more than 9 levels
- facet_grid fail with a category type
- facet_grid repeat x-axis
- pandas sort issue
- How about make it available with dfply?
- Link to an actively developed project called "plotnine" which provides ggplot functionality in python.
- ggplot installs for python3.9.1.0, but import ggplot gets error re pandas attribute tslib HOT 2
- plot multiple geoms on top of each other
- Looking for `ggplot` substitution HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggpy.