草庐IT

python - 类型错误 : float() argument must be a string or a number in Django distance

我试图从我的模板中获取kmdistance的值,但当我查看页面时它返回错误。这是views.pydefdisplay_maps(request):#basesforcityproperpnt=ButuanMaps.objects.get(clandpin='162-03-0001-017-33').geom#landproperty__sownerid__id=5isforgovernmentuserkmdistance=request.GET.get("kmtocity",None)mysection=(request.GET.get("mysection",None))query_

python - Pandas 数据框 : ValueError: num must be 1 <= num <= 0, 不是 1

我在尝试绘制pandasdataframe时遇到以下错误:ValueError:nummustbe1代码:importmatplotlib.pyplotaspltnames=['buying','maint','doors','persons','lug_boot','safety']custom=pd.DataFrame(x_train)//onlyaportionofthecsvcustom.columns=namescustom.hist()plt.show()我尝试再次从csv读取文件,但我得到了完全相同的错误。编辑:printx_train输出:[[0.00.00.00.00

python - 为什么我在安装时不断收到此消息说 EntryPoint must be in 'name=module :attrs [extras]

您好,我在OSxMavericks上,使用python2.7和pip6.0.8版以及setuptools12.2版。当我尝试安装我的项目时,我收到警告消息但安装成功$pythonsetup.pyinstall--user如果我使用distutils,我会收到以下消息,它的设置可能没有kwargentry_points。/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267:UserWarning:未知分发选项:'entry_points'警告。警告(消息)但是当我尝试通过

python - Pandas drop_duplicates - TypeError : type object argument after * must be a sequence, 未映射

我更新了我的问题以提供更清晰的示例。是否可以使用Pandas中的drop_duplicates方法根据值包含列表的列ID删除重复行。考虑由列表中的两个项目组成的“三”列。有没有一种方法可以删除重复的行而不是反复进行(这是我目前的解决方法)。我通过提供以下示例概述了我的问题:importpandasaspddata=[{'one':50,'two':'5:00','three':'february'},{'one':25,'two':'6:00','three':['february','january']},{'one':25,'two':'6:00','three':['februa

python - 类型错误 : unbound method "method name" must be called with "Class name" instance as first argument (got str instance instead)

我认为这应该是一个简单的问题。我有下一节课:classGruposHandler(webapp.RequestHandler):defget(self):self.obtenerPagina()defobtenerPagina(self,pOpcion=None,pMensajeInformacion=None):opcion=pOpcionifpOpcionisnotNoneelseself.request.get('opcion')usuario=obtenerUsuario()rsGrupos=obtenerGruposAll()listaOtrosGrupos=[]listaG

python - 值错误 ("color kwarg must have one color per dataset")?

我只是简单地将数据保存到文件中并读出它们,然后绘制直方图。但是,尽管我实际上没有对原始代码进行任何更改,但似乎出现了这个错误。谁能告诉我怎么了?非常感谢。这是hist()的代码f_120=plt.figure(1)plt.hist(tfirst_list,bins=6000000,normed=True,histtype="step",cumulative=True,color='g',label='firstanswer')plt.axvline(x=30,ymin=0,ymax=1,color='r',linestyle='--',label='30min')plt.axvline

python - 使用 python 运行 bash 脚本 - TypeError : bufsize must be an integer

我正在尝试编写python文件,即python中的wxtractar文件。据我所知,subprocess是完成此任务的合适工具。我写了下面的代码:fromsubprocessimportcalldeftarfile(path):call(["tar"],path)if__name__=="__main__":tarfile("/root/tryit/output.tar")当输出为tar文件时,位于/root/tryit/。当我运行它时,我收到以下消息:TypeError:bufsizemustbeaninteger我可以通过这个工具使用tar命令吗? 最佳

python - 您的 "must-have"金融 Python 包是什么?

随着最近SECproposal要求大多数Assets支持证券发行人提交一个python计算机程序来记录交易的资金流(或瀑布)规定,我认为现在是时候问你认为金融“必备”Python包是什么了。PS:除了在这里回答,还请考虑回答thissurvey.更新:调查结果here. 最佳答案 http://code.google.com/p/pandas/也是量化金融背景下开发的。我想那是通常的嫌疑人:NumPy科学努力matplotlib...对于我的量化开发,我通常以pythonxy(http://www.pythonxy.com/)作为基

python - 如何切片 2D Python 数组? : "TypeError: list indices must be integers, not tuple" 失败

我在numpy模块中有一个二维数组,如下所示:data=array([[1,2,3],[4,5,6],[7,8,9]])我想得到这个数组的一部分,它只包含元素的某些列。例如,我可能需要第0列和第2列:data=[[1,3],[4,6],[7,9]]最符合Pythonic的方法是什么?(请不要循环)我认为这会起作用:newArray=data[:,[0,2]]但结果是:TypeError:listindicesmustbeintegers,nottuple 最佳答案 错误明确地说:数据不是一个numpy数组,而是一个列表列表。首先尝试

python - OpenCV ORB 描述符 : TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)

我遵循了这个简单的OpenCVFeatureMatchingexample正是:importcv2img=cv2.imread('box.png',0)#queryImageorb=cv2.ORB()#InitiateORBdetector#findthekeypointsanddescriptorswithORBkp1,des1=orb.detectAndCompute(img,None)出现以下错误:TypeError:Incorrecttypeofself(mustbe'Feature2D'oritsderivative)我正在使用OpenCV3.3.1