Comments (9)
I'm getting this sporadically as well. I'll take a look but it looks like ggplot is passing an invalid data type to statsmodels. Does it work with method="lm" for stat_smooth?
On Oct 15, 2013, at 10:05 AM, Bart [email protected] wrote:
For every example I try (be it in IPython or not) I get the following error:
File "ggplot_test.py", line 11, in
ggsave(p, "test.png")
File "C:\Python27\lib\site-packages\ggplot\utils\utils.py", line 4, in ggsave
print (plot)
File "C:\Python27\lib\site-packages\ggplot\ggplot.py", line 209, in repr
callbacks = geom.plot_layer(layer)
File "C:\Python27\lib\site-packages\ggplot\geoms\stat_smooth.py", line 37, in plot_layer
y, y1, y2 = smoothers.lowess(x, y)
File "C:\Python27\lib\site-packages\ggplot\components\smoothers.py", line 38, in lowess
result = smlowess(np.array(y), np.array(x), frac=span)
File "C:\Python27\lib\site-packages\statsmodels\nonparametric\smoothers_lowess.py", line 128, in lowess
exog = np.asarray(exog, float)
File "C:\Python27\lib\site-packages\numpy-1.7.0-py2.7-win32.egg\numpy\core\numeric.py", line 320, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number
The specific example:from ggplot import *
p = ggplot(aes(x='date', y='beef'), data=meat) +
geom_point(color='lightblue') +
geom_line(alpha=0.25) +
stat_smooth(span=.05, color='black') +
ggtitle("Beef: It's What's for Dinner") +
xlab("Date") +
ylab("Head of Cattle Slaughtered")ggsave(p, "test.png")
—
Reply to this email directly or view it on GitHub.
from ggpy.
I get a different error when using method="lm"
File "ryp_ggplot.py", line 11, in <module>
ggsave(p, "test.png")
File "C:\Python27\lib\site-packages\ggplot\utils\utils.py", line 4, in ggsave
print (plot)
File "C:\Python27\lib\site-packages\ggplot\ggplot.py", line 209, in __repr__
callbacks = geom.plot_layer(layer)
File "C:\Python27\lib\site-packages\ggplot\geoms\stat_smooth.py", line 33, in plot_layer
y, y1, y2 = smoothers.lm(x, y)
File "C:\Python27\lib\site-packages\ggplot\components\smoothers.py", line 24, in lm
fit = sm.OLS(df.y,df[['x','const']]).fit()
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 479, in __init__
hasconst=hasconst)
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 381, in __init__
weights=weights, hasconst=hasconst)
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 79, in __init__
super(RegressionModel, self).__init__(endog, exog, **kwargs)
File "C:\Python27\lib\site-packages\statsmodels\base\model.py", line 137, in __init__
self.initialize()
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 88, in initialize
self.rank = rank(self.exog)
File "C:\Python27\lib\site-packages\statsmodels\tools\tools.py", line 381, in rank
D = svdvals(X)
File "C:\Python27\lib\site-packages\scipy\linalg\decomp_svd.py", line 146, in svdvals
check_finite=check_finite)
File "C:\Python27\lib\site-packages\scipy\linalg\decomp_svd.py", line 100, in svd
full_matrices=full_matrices, overwrite_a=overwrite_a)
TypeError: float() argument must be a string or a number
I does however work when omitting stat_smooth()
from ggpy.
Ok thanks for debugging. Should be able to patch this fairly easily.
In other news, the scipy stack trace sure is nasty!
On Oct 15, 2013, at 10:34 AM, Bart [email protected] wrote:
I get a different error when using method="lm"
File "ryp_ggplot.py", line 11, in
ggsave(p, "test.png")
File "C:\Python27\lib\site-packages\ggplot\utils\utils.py", line 4, in ggsave
print (plot)
File "C:\Python27\lib\site-packages\ggplot\ggplot.py", line 209, in repr
callbacks = geom.plot_layer(layer)
File "C:\Python27\lib\site-packages\ggplot\geoms\stat_smooth.py", line 33, in plot_layer
y, y1, y2 = smoothers.lm(x, y)
File "C:\Python27\lib\site-packages\ggplot\components\smoothers.py", line 24, in lm
fit = sm.OLS(df.y,df[['x','const']]).fit()
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 479, in init
hasconst=hasconst)
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 381, in init
weights=weights, hasconst=hasconst)
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 79, in init
super(RegressionModel, self).init(endog, exog, **kwargs)
File "C:\Python27\lib\site-packages\statsmodels\base\model.py", line 137, in init
self.initialize()
File "C:\Python27\lib\site-packages\statsmodels\regression\linear_model.py", line 88, in initialize
self.rank = rank(self.exog)
File "C:\Python27\lib\site-packages\statsmodels\tools\tools.py", line 381, in rank
D = svdvals(X)
File "C:\Python27\lib\site-packages\scipy\linalg\decomp_svd.py", line 146, in svdvals
check_finite=check_finite)
File "C:\Python27\lib\site-packages\scipy\linalg\decomp_svd.py", line 100, in svd
full_matrices=full_matrices, overwrite_a=overwrite_a)
TypeError: float() argument must be a string or a number
I does however work when omitting stat_smooth()—
Reply to this email directly or view it on GitHub.
from ggpy.
I was getting this error if I had a really old version of pandas installed.
from ggpy.
I had the same results as @desilinguist. If you pip install pandas it should remove these errors.
from ggpy.
Thanks! This worked for me too.
$ pip install -U pandas
On Tue, Oct 15, 2013 at 2:55 PM, Stefan Eng [email protected]:
I had the same results as @desilinguist https://github.com/desilinguist.
If you pip install pandas it should remove these errors.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-26362095
.
from ggpy.
Hmz, unfortunately I still can't get the stat_smooth function working. I updated pandas to v. 0.12.0 and made sure the other required packages are also up-to-date. I however keep getting this error:
Traceback (most recent call last):
File "ggplot.py", line 9, in <module>
ylab("Head of Cattle Slaughtered")
File "C:\Python27\lib\site-packages\ggplot\ggplot.py", line 209, in __repr__
callbacks = geom.plot_layer(layer)
File "C:\Python27\lib\site-packages\ggplot\geoms\stat_smooth.py", line 37, in plot_layer
y, y1, y2 = smoothers.lowess(x, y)
File "C:\Python27\lib\site-packages\ggplot\components\smoothers.py", line 38, in lowess
result = smlowess(np.array(y), np.array(x), frac=span)
File "C:\Python27\lib\site-packages\statsmodels\nonparametric\smoothers_lowess.py", line 128, in lowess
exog = np.asarray(exog, float)
File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line 460, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number
When using this example:
from ggplot import *
print ggplot(aes(x='date', y='beef'), data=meat) + \
geom_point(color='lightblue') + \
geom_line(alpha=0.25) + \
stat_smooth(span=.05, color='black') + \
ggtitle("Beef: It's What's for Dinner") + \
xlab("Date") + \
ylab("Head of Cattle Slaughtered")
plt.show(1)
from ggpy.
@bart6114 are you sure pandas actually got upgraded? Pip is pretty notorious for not following through with upgrades if you have an older version of the package in some /tmp/pip*
build directory. I'd double-check by importing pandas and checking the output of pandas.__version__
.
from ggpy.
Thanks @dan-blanchard , that was the problem!
from ggpy.
Related Issues (20)
- [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
- Questions about Copilot + Open Source Software Hierarchy
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.