dashee87 / blogScripts

Repository for code used in my blog posts
MIT License
386 stars 247 forks source link

only length-1 arrays can be converted to Python scalars #4

Open zawmoetun opened 6 years ago

zawmoetun commented 6 years ago

Dear Sir, Very appreciate your efforts. When I am running "2017-06-04-predicting-football-results-with-statistical-modelling", I get below errors. I used Anaconda framework. Even I run at command prompt, I still get this error. Python version 3.6.4 64 bit and it is running on Mac. Can you pls. help to me. I an very new to Python. Best Regards, Zaw


TypeError Traceback (most recent call last)

in () 12 sun_away_pois = [poisson.pmf(i,np.sum(np.multiply(sun_home.values.T,sun_home.index.T),axis=1)[0]) for i in range(8)] 13 ---> 14 ax1.bar(chel_home.index-0.4,chel_home.values,width=0.4,color="#034694",label="Chelsea") 15 ax1.bar(sun_home.index,sun_home.values,width=0.4,color="#EB172B",label="Sunderland") 16 pois1, = ax1.plot([i for i in range(8)], chel_home_pois, ~/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs) 1708 warnings.warn(msg % (label_namer, func.__name__), 1709 RuntimeWarning, stacklevel=2) -> 1710 return func(ax, *args, **kwargs) 1711 pre_doc = inner.__doc__ 1712 if pre_doc is None: ~/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in bar(self, *args, **kwargs) 2146 edgecolor=e, 2147 linewidth=lw, -> 2148 label='_nolegend_', 2149 ) 2150 r.update(kwargs) ~/anaconda3/lib/python3.6/site-packages/matplotlib/patches.py in __init__(self, xy, width, height, angle, **kwargs) 687 """ 688 --> 689 Patch.__init__(self, **kwargs) 690 691 self._x = xy[0] ~/anaconda3/lib/python3.6/site-packages/matplotlib/patches.py in __init__(self, edgecolor, facecolor, color, linewidth, linestyle, antialiased, hatch, fill, capstyle, joinstyle, **kwargs) 131 self.set_fill(fill) 132 self.set_linestyle(linestyle) --> 133 self.set_linewidth(linewidth) 134 self.set_antialiased(antialiased) 135 self.set_hatch(hatch) ~/anaconda3/lib/python3.6/site-packages/matplotlib/patches.py in set_linewidth(self, w) 379 w = mpl.rcParams['axes.linewidth'] 380 --> 381 self._linewidth = float(w) 382 # scale the dash pattern by the linewidth 383 offset, ls = self._us_dashes TypeError: only length-1 arrays can be converted to Python scalars