Я сталкиваюсь с ошибкой AttributeError в python коде, связанном с моделью прогнозирования - PullRequest
0 голосов
/ 09 января 2020

Я работаю над моделью прогнозирования в python. Я пробовал разные примеры кодов. Я сталкиваюсь с ошибкой атрибута в коде, которая утверждает, что существует некоторая проблема из-за сюжета пакета.

AttributeError                            Traceback (most recent call last)
<ipython-input-43-0fd6c75392f2> in <module>
      7 
      8 df_EF = df_EducationField.groupby(by="Field").sum()
----> 9 df_EF.iplot(kind='bar',title='Leavers by Education Field(%)')

/anaconda3/lib/python3.6/site-packages/cufflinks/plotlytools.py in _iplot(self, kind, data, layout, filename, sharing, title, xTitle, yTitle, zTitle, theme, colors, colorscale, fill, width, dash, mode, interpolation, symbol, size, barmode, sortbars, bargap, bargroupgap, bins, histnorm, histfunc, orientation, boxpoints, annotations, keys, bestfit, bestfit_colors, mean, mean_colors, categories, x, y, z, text, gridcolor, zerolinecolor, margin, labels, values, secondary_y, secondary_y_title, subplots, shape, error_x, error_y, error_type, locations, lon, lat, asFrame, asDates, asFigure, asImage, dimensions, asPlot, asUrl, online, **kwargs)
    840                 data=df.to_iplot(colors=colors,colorscale=colorscale,kind=kind,interpolation=interpolation,fill=fill,width=width,dash=dash,sortbars=sortbars,keys=keys,
    841                                                 bestfit=bestfit,bestfit_colors=bestfit_colors,mean=mean,mean_colors=mean_colors,asDates=asDates,mode=mode,symbol=symbol,size=size,
--> 842                         text=text,**kwargs)     
    843                                 trace_kw=check_kwargs(kwargs,TRACE_KWARGS)
    844                                 for trace in data:

/anaconda3/lib/python3.6/site-packages/cufflinks/plotlytools.py in _to_iplot(self, colors, colorscale, kind, mode, interpolation, symbol, size, fill, width, dash, sortbars, keys, bestfit, bestfit_colors, opacity, mean, mean_colors, asDates, asTimestamp, text, **kwargs)
    158                                 lines[key]["fillcolor"]=to_rgba(colors[key],kwargs['opacity'] if 'opacity' in kwargs else .3            )
    159         if 'bar' in kind:
--> 160                 lines_plotly=[Bar(lines[key]).to_plotly_json() for key in keys]
    161         else:
    162                 lines_plotly=[Scatter(lines[key]).to_plotly_json() for key in keys]

/anaconda3/lib/python3.6/site-packages/cufflinks/plotlytools.py in <listcomp>(.0)
    158                                 lines[key]["fillcolor"]=to_rgba(colors[key],kwargs['opacity'] if 'opacity' in kwargs else .3            )
    159         if 'bar' in kind:
--> 160                 lines_plotly=[Bar(lines[key]).to_plotly_json() for key in keys]
    161         else:
    162                 lines_plotly=[Scatter(lines[key]).to_plotly_json() for key in keys]

/anaconda3/lib/python3.6/site-packages/plotly/graph_objs/__init__.py in __init__(self, arg, alignmentgroup, base, basesrc, cliponaxis, constraintext, customdata, customdatasrc, dx, dy, error_x, error_y, hoverinfo, hoverinfosrc, hoverlabel, hovertemplate, hovertemplatesrc, hovertext, hovertextsrc, ids, idssrc, insidetextanchor, insidetextfont, legendgroup, marker, meta, metasrc, name, offset, offsetgroup, offsetsrc, opacity, orientation, outsidetextfont, r, rsrc, selected, selectedpoints, showlegend, stream, t, text, textangle, textfont, textposition, textpositionsrc, textsrc, texttemplate, texttemplatesrc, tsrc, uid, uirevision, unselected, visible, width, widthsrc, x, x0, xaxis, xcalendar, xsrc, y, y0, yaxis, ycalendar, ysrc, **kwargs)

AttributeError: module 'plotly.validators.bar' has no attribute 'TexttemplateValidator'

Ниже приведен фрагмент кода

df_EducationField = pd.DataFrame(columns=["Field","% of Leavers"])
i=0
for field in list(df_HR['EducationField'].unique()):
    ratio=df_HR[(df_HR['EducationField']==field)&(df_HR['Attrition']=="Yes")].shape[0]/df_HR[df_HR['EducationField']==field].shape[0]
    df_EducationField.loc[i]=(field,ratio*100)
    i+=1

df_EF = df_EducationField.groupby(by="Field").sum()
df_EF.iplot(kind='bar',title='Leavers by Education Field(%)')
...