草庐IT

numeric_traits_integer

全部标签

python - 类型错误 : only integer arrays with one element can be converted to an index 3

我在标题中有这个错误,不知道出了什么问题。当我使用np.hstack而不是np.append时它可以工作,但我想让它更快,所以使用append。time_listalistoffloatsheightsisa1dnp.arrayoffloatsj=0n=30time_interval=1200axe_x=[]whilejFile"....",line..,inaxe_x.append(time_list[np.arange(j+n,j+(time_interval-n))])TypeError:onlyintegerarrayswithoneelementcanbeconvertedt

Python Pandas : output dataframe to csv with integers

我有一个希望导出到CSV文件的pandas.DataFrame。但是,pandas似乎将一些值写为float而不是int类型。我找不到如何改变这种行为。构建数据框:df=pandas.DataFrame(columns=['a','b','c','d'],index=['x','y','z'],dtype=int)x=pandas.Series([10,10,10],index=['a','b','d'],dtype=int)y=pandas.Series([1,5,2,3],index=['a','b','c','d'],dtype=int)z=pandas.Series([1,2,

python - 何时在 python 中应用(pd.to_numeric)和何时 astype(np.float64)?

我有一个名为xiv的pandasDataFrame对象,其中有一列int64体积测量值。In[]:xiv['Volume'].head(5)Out[]:0252000148400026200031680004232000Name:Volume,dtype:int64我已阅读其他建议以下解决方案的帖子(如this和this)。但是当我使用任何一种方法时,它似乎都不会改变底层数据的dtype:In[]:xiv['Volume']=pd.to_numeric(xiv['Volume'])In[]:xiv['Volume'].dtypesOut[]:dtype('int64')或者……In[]

尝试按索引访问列表时出现 Python 错误 - "List indices must be integers, not str"

我有以下Python代码:currentPlayers=query.getPlayers()forplayerincurrentPlayers:returnstr(player['name'])+""+str(player['score'])我收到以下错误:TypeError:listindicesmustbeintegers,notstr我一直在寻找与我接近的错误,但不知道该怎么做,从未遇到过该错误。所以是的,我怎样才能将它转换为整数而不是字符串?我猜问题出在str(player['score']). 最佳答案 您是否希望play

python - 类型错误 : only integer arrays with one element can be converted to an index

使用交叉验证执行递归特征选择时出现以下错误:Traceback(mostrecentcalllast):File"/Users/.../srl/main.py",line32,inargident_sys.train_classifier()File"/Users/.../srl/identification.py",line194,intrain_classifierfeat_selector.fit(train_argcands_feats,train_argcands_target)File"/Library/Frameworks/Python.framework/Version

python 'list indices must be integers, not tuple"

这两天我一直在努力解决这个问题。我是python和编程的新手,所以此类错误的其他示例对我没有太大帮助。我正在阅读列表和元组的文档,但没有找到任何有用的东西。任何指针将不胜感激。不一定要寻找答案,只是寻找更多资源。我正在使用Python2.7.6。谢谢measure=raw_input("Howwouldyouliketomeasurethecoins?Enter1forgrams2forpounds.")coin_args=[["pennies",'2.5','50.0','.01']["nickles",'5.0','40.0','.05']["dimes",'2.268','50.

python - TypeError : string indices must be integers, not str//使用 dict

我正在尝试定义一个过程,involved(courses,person),它将类(class)结构和人员作为输入,并返回描述该人员所参与的所有类(class)的字典。这是我的involved(courses,person)函数:definvolved(courses,person):fortime1incourses:forcourseincourses[time1]:forinfointime1[course]:printinfo这是我的字典:courses={'feb2012':{'cs101':{'name':'BuildingaSearchEngine','teacher':'

python - Pandas 数据帧 "no numeric data to plot"错误

我有一个小DataFrame,我想使用pandas进行绘图。2301300100012427511491994468272237712649194704827316.223.0我仍在尝试从pandas中学习绘图。我想要一个情节在上面的例子中当我说。df.plot()我遇到了最奇怪的错误。Library/Python/2.7/site-packages/pandas-0.16.2-py2.7-macosx-10.10-intel.egg/pandas/tools/plotting.pycin_compute_plot_data(self)1015ifis_empty:1016raiseT

javascript - GraphQL 大整数错误 : Int cannot represent non 32-bit signed integer value

我正在尝试使用GraphQL在MongoDB中存储UNIX时间戳,但它发现GraphQL在处理整数方面存在限制。请参阅下面的突变:constaddUser={type:UserType,description:'Addanuser',args:{data:{name:'data',type:newGraphQLNonNull(CompanyInputType)}},resolve(root,params){params.data.creationTimestamp=Date.now();constmodel=newUserModel(params.data);constsaved=mo

javascript - GraphQL 大整数错误 : Int cannot represent non 32-bit signed integer value

我正在尝试使用GraphQL在MongoDB中存储UNIX时间戳,但它发现GraphQL在处理整数方面存在限制。请参阅下面的突变:constaddUser={type:UserType,description:'Addanuser',args:{data:{name:'data',type:newGraphQLNonNull(CompanyInputType)}},resolve(root,params){params.data.creationTimestamp=Date.now();constmodel=newUserModel(params.data);constsaved=mo