草庐IT

current_index

全部标签

python - 为什么 psycopg2 不执行我的任何 SQL 函数? (索引错误 : tuple index out of range)

我以最简单的SQL函数为例:CREATEORREPLACEFUNCTIONskater_name_match(INTEGER,VARCHAR)RETURNSBOOLAS$$SELECT$1IN(SELECTskaters_skater.competitor_ptr_idFROMskaters_skaterWHEREname||''||surnameILIKE'%'||$2||'%'ORsurname||''||nameILIKE'%'||$2||'%');$$LANGUAGESQL;如果我将它复制并粘贴到psql(PostgreSQL的shell)中,那么它会毫无问题地执行。如果我写一

python - 有没有更好的方法来使用 Tornado 处理 index.html?

我想知道是否有更好的方法来使用Tornado处理我的index.html文件。我对所有请求都使用StaticFileHandler,并使用特定的MainHandler来处理我的主要请求。如果我只使用StaticFileHandler我得到一个403:Forbidden错误GEThttp://localhost:9000/WARNING:root:403GET/(127.0.0.1):isnotafile我现在的情况:importosimporttornado.ioloopimporttornado.webfromtornadoimportweb__author__='gvincent'

python - ipython : get access to current figure()

我想在绘制的图形上添加更细粒度的网格。问题是所有示例都需要访问Axis对象。我想将特定的网格添加到已经绘制的图形中(从ipython内部)。如何在ipython中访问当前图形和Axis? 最佳答案 plt.gcf()获取当前图形plt.gca()获取当前坐标Axis 关于python-ipython:getaccesstocurrentfigure(),我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/

python - 值错误 : Cannot set a frame with no defined index and a value that cannot be converted to a Series

我在我的python3.X中使用Pandas0.20.3。我想在另一个Pandas数据框中的Pandas数据框中添加一列。两个数据框都包含51行。所以我使用了以下代码:class_df['phone']=group['phone'].values我收到以下错误消息:ValueError:CannotsetaframewithnodefinedindexandavaluethatcannotbeconvertedtoaSeriesclass_df.dtypes给我:Group_IDobjectYEARobjectTergetobjectphoneobjectageobject和type(

python - 为什么heroku local :run wants to use the global python installation instead of the currently activated virtual env?

使用Heroku部署我们的Django应用程序,除了herokulocal:run命令之外,一切似乎都符合规范。我们经常需要通过Django的manage.py文件来运行命令。在Remote上运行它们,作为一次性的测功机,完美无缺。要在本地运行它们,我们尝试:herokulocal:runpythonmanage.pythe_command尽管当前虚拟环境包含Django安装,但失败了,ImportError:Nomodulenameddjango.core.management 通过python路径诊断然后herokulocal:runwhichpython返回:/usr/local

python / Pandas : how to combine two dataframes into one with hierarchical column index?

我有两个如下所示的数据框:>>>df1AB2000-01-011.41.42000-01-021.7-1.92000-01-03-0.2-0.8>>>df2AB2000-01-010.6-0.32000-01-02-0.40.62000-01-031.1-1.0如何使用下面的分层列索引从这两个数据帧中创建一个数据帧?df1df2ABAB2000-01-011.41.40.6-0.32000-01-021.7-1.9-0.40.62000-01-03-0.2-0.81.1-1.0 最佳答案 这是一个文档示例:http://pandas

python - Tensorflow : What is the relationship between . ckpt 文件和 .ckpt.meta 和 .ckpt.index 和 .pb 文件

我使用saver=tf.train.Saver()来保存我训练的模型,我得到了三种文件,命名为:.ckpt.meta.ckpt.index.ckpt.data还有一个文件叫:检查点与.ckpt文件有什么关系?我看到有人保存的模型只有.ckpt文件,我不知道如何制作。如何将模型保存为.pb文件? 最佳答案 .ckpt文件是saver.save(sess)的旧版本输出,相当于您的.ckpt-data(见下文)“检查点”文件只是在这里告诉一些TF函数哪个是最新的检查点文件。.ckpt-meta包含元图,即计算图的结构,没有变量的值(基本上

python - Django:unique_together 是否以与 ForeignKey 相同的方式暗示 db_index=True?

模型上的一个字段,foo=models.ForeignKey(Foo)会自动为该列添加一个数据库索引,以加快查找速度。这很好,但是Django的文档没有说明模型元的unique_together中的字段是否接受相同的处理。我碰巧有一个模型,其中unique_together中列出的一个char字段需要一个索引以进行快速查找。我知道在字段定义中添加重复的db_index=True不会有什么坏处,但我很好奇。 最佳答案 如果有人来这里想知道除了unique_together是否还需要一个index_together来获得索引的性能优势,

python - 尝试访问第 N 个项目时出现 "IndexError: list index out of range"是否意味着我的列表中的项目少于 N 个?

我告诉我的程序打印输出的第53行。这个错误是否告诉我没有那么多行,因此无法打印出来? 最佳答案 如果您有一个包含53个项目的列表,则最后一个是thelist[52],因为索引从0开始。来自RealPython:UnderstandingthePythonTraceback-IndexError:IndexErrorTheIndexErrorisraisedwhenyouattempttoretrieveanindexfromasequence,likealistoratuple,andtheindexisn’tfoundinthes

python - 如何正确地将小时数添加到 pandas.tseries.index.DatetimeIndex?

我有一个普通的df.index,我想增加几个小时。In[1]:test[1].indexOut[2]:[2010-03-11,...,2014-08-14]Length:52,Freq:None,Timezone:None这是第一个元素的样子:In[1]:test[1].index[0]Out[2]:Timestamp('2010-03-1100:00:00')所以我试试这个来增加时间:In[1]:test[1].index[0]+pd.tseries.timedeltas.to_timedelta(16,unit='h')但是我明白了:Out[2]:Timestamp('2010-0