草庐IT

assign_attributes

全部标签

python - 属性错误 : 'module' object has no attribute 'SFrame'

我正在Coursera上ML类(class),我已经安装了GraphLabCreate和ipythonnotebook。我是ML和python的新手。我得到以下错误,importgraphlabsf=graphlab.SFrame('people-example.csv')AttributeErrorTraceback(mostrecentcalllast)in()---->1sf=graphlab.SFrame('people-example.csv')AttributeError:'module'objecthasnoattribute'SFrame'我该如何修复这个错误?我的pe

python - 属性错误 : 'module' object has no attribute 'xfeatures2d' [Python/OpenCV 2. 4]

这一行:sift=cv2.xfeatures2d.SIFT_create()返回错误:Traceback(mostrecentcalllast):File"C:/Python27/openCVskrypty/GUI/SOLUTION2.py",line11,insift=cv2.xfeatures2d.SIFT_create()AttributeError:'module'objecthasnoattribute'xfeatures2d'我阅读了一些有关此错误的信息,它出现在OpenCV3.0版中。这很奇怪,因为我有2.4.11版本。我检查了dir(cv2),但没有xfeatures2

python - 诅咒返回 AttributeError : 'module' object has no attribute 'initscr'

我正在关注CursesprogrammingHowToonthePythonsite,但我遇到了一个相当奇怪的问题。我的代码目前非常短,实际上没有做任何事情因为这个错误,我无法继续前进。这是我的代码:importcurses#fromcursesimportwrapperstdscr=curses.initscr()curses.noecho()curses.cbreak()stdscr.keypad(True)defmain(stdscr):begin_x=20;begin_y=7height=5;width=40win=curses.newwin(height,width,begi

python 3 : AttributeError: 'module' object has no attribute '__path__' using urllib in terminal

我的代码在PyCharm中运行完美,但我在尝试在终端中打开它时收到错误消息。我的代码有什么问题,或者我哪里出错了?importurllib.requestwithurllib.request.urlopen('http://python.org/')asresponse:html=response.read()print(html)终端输出:λpythonDesktop\url1.pyTraceback(mostrecentcalllast):File"",line2218,in_find_and_load_unlockedAttributeError:'module'objectha

python - pyspark 错误 : AttributeError: 'SparkSession' object has no attribute 'parallelize'

我在Jupyternotebook上使用pyspark。以下是Spark的设置方式:importfindsparkfindspark.init(spark_home='/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive',python_path='python2.7')importpysparkfrompyspark.sqlimport*sc=pyspark.sql.SparkSession.builder.master("yarn-client").config("spark.executor.memo

python - 必须使用某种集合调用索引 : assign column name to dataframe

我有reweightTarget如下,我想将它转换为pandasDataframe。但是,我收到以下错误:TypeError:Index(...)mustbecalledwithacollectionofsomekind,'t'waspassed如果我删除columns='t',它工作正常。谁能解释一下这是怎么回事?reweightTargetTradingdates2004-01-314.352004-02-294.462004-03-314.442004-04-304.392004-05-314.502004-06-304.532004-07-314.632004-08-314.5

python - : python string assignments accidentally change '\b' into '\x08' and '\a' into '\x07' , 为什么 Python 这样做?

有两个答案和一些评论,提到了另一个问题,但都没有提供REASON,Python为什么要这样修改?比如'/b'is'/x08'只是结果,但是为什么呢?干杯。我尝试添加这个路径“F:\bigdata\Python_coding\diveintopython-5.4\py”进入sys.path,因此可以直接导入其下的代码。使用后:sys.path.append('F:\bigdata\Python_coding\diveintopython-5.4\py')我发现我在sys.path中有这条路径:'F:\x08igdata\Python_coding\diveintopython-5.4\p

python - Django ORM : Filter by extra attribute

我想通过连接的字符串过滤一些数据库对象。正常的SQL查询是:SELECTconcat(firstName,'',name)FROMpersonWHERECONCAT(firstName,'',name)LIKE"a%";在模型中,我创建了一个名为PersonObjects的管理器:classPersonObjects(Manager):attrs={'fullName':"CONCAT(firstName,'',name)"}defget_query_set(self):returnsuper(PersonObjects,self).get_query_set().extra(sele

python - matplotlib.pyplot.imshow : removing white space within plots when using attributes "sharex" and "sharey"

我遇到了一个类似于here上发布的问题.不同之处在于,当我绘制两个通过sharex和sharey属性共享轴的子图时,我在绘图区域内得到不需要的空白。即使在设置autoscale(False)之后,空白仍然存在。例如,使用与上述帖子的答案中类似的代码:importmatplotlib.pyplotaspltimportnumpyasnpfig=plt.figure()ax=fig.add_subplot(2,1,1)ax.imshow(np.random.random((10,10)))ax.autoscale(False)ax2=fig.add_subplot(2,1,2,sharex

python - 属性错误 : 'FreqDist' object has no attribute 'inc'

我是Python和NLTK的初学者。我正在尝试运行教程中的以下代码:fromnltk.corpusimportgutenbergfromnltkimportFreqDistfd=FreqDist()forwordingutenberg.words('austen-sense.txt'):fd.inc(word)如果我运行它,我会收到以下错误:AttributeError:'FreqDist'objecthasnoattribute'inc'知道我做错了什么吗? 最佳答案 你应该这样做:fd[word]+=1但通常FreqDist是这