我使用了一个调试,我会收到以下错误:PHP致命错误unculting typeError:ceil():参数#1($ num)必须为type int | float,字符串,在/var/www/www/html/wp中给出. -content/themes/ark/footer.php:20 该行的读数是这样: $linkOffsetSM = ceil( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset-sm', '') ); 完整的Div:
以下是关于 typeerror 的编程技术问答
我有以下错误: PHP message: PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string 在这条线上: if ($uploadZoneData[1]['size'] != 0) { 在PHP 7.4上,我有任何Troube,但我有Php 8. 有什么问题? 编辑:相关功能的完整代码: function uploadSingleFile($zoneImage, $fileMoveTo, $fileAllowedExtensions, $fileAllowedSize, $zoneCustomer, $zone) { global $config; // define file upload settings $errors = array(); $fileName = $zoneImage['name'
使用以下代码,我想>打开文件>读取内容并剥离非要求行>然后将数据写入文件,并读取文件以进行下游分析. with open("chr2_head25.gtf", 'r') as f,\ open('test_output.txt', 'w+') as f2: for lines in f: if not lines.startswith('#'): f2.write(lines) f2.close() 现在,我想读取F2数据并在熊猫或其他模块中进行进一步处理,但是我在阅读数据时遇到了问题(f2). data = f2 # doesn't work print(data) #gives data = io.StringIO(f2) # doesn't work # Err
我有将字符串'AAAABBBCCDAABBB'纳入这样的列表的任务:['A','B','C','D','A','B'] 我现在正在研究这个问题2个小时,我无法获得解决方案.到目前为止,这是我的代码: list = [] string = 'AAAABBBCCDAABBB' i = 1 for i in string: list.append(i) print(list) for element in list: if list[element] == list[element-1]: list.remove(list[element]) print(list) 我是编程的新手,错误" typeError:列表索引必须是整数或切片,而不是str"总是显示... 我已经更改了比较 if list[element] == list[element-1] to if list[element] is list[el
我真的很拼命地将我的字符串数值转换为整数的最后日子,所以我尝试了: 快照: 代码试验: follower_count = int(browser.find_element_by_xpath('/html/body/div[1]/section/main/div/header/section/ul/li[2]/a/span').text) convert_follower_count = re.sub('[^0-9]','', follower_count) ...不起作用: Traceback (most recent call last): File "C:\Users\Desktop\TwitPy\quickstart.py", line 79, in followers_count = re.sub('[^0-9]','', follower_count) File "C:\Users\AppData\Local\Progra
以下代码部分给了我错误 fd=((1/(sd*sqrt(6.28)))*2.718**((-1(d-average)**2))/(2*sd**2))) 这是错误 Traceback (most recent call last): File "C:\Users\etc fd=((1/(sd*sqrt(6.28)))*2.718**((-1(d-average)**2))/(2*sd**2)) TypeError: 'int' object is not callable 我找不到int对象在哪里"不可呼出" 谢谢 解决方案 您缺少-1之后的*操作员. 其他解决方案 这是由python试图"调用"这样的int对象产生的: >>> 2*(1+3) 8 >>> 2(1+3) #note missing * Traceback (most recent call last): File "", line
我在这里看不到问题,但是Python认为不同: x = 3 y = 7 z = 2 print "I told to the Python, that the first variable is %d!" % x print "Anyway, 2nd and 3rd variables sum is %d. :)" % y + z 我得到TypeError: cannot concatenate 'str' and 'int' objects. 为什么这样?我还没有将任何变量设置为字符串... 解决方案 %的优先级高于+,因此s % y + z被解析为(s % y) + z. . 如果s是字符串,则s % x是字符串,(s % y) + z尝试添加字符串(s % y的结果)和一个整数(z的值). p> 其他解决方案 您需要放置括号:(y+z)
如果您的问题被关闭以重复,那是因为您有一个代码样本,其中包括一条线: class Example: def __int__(self, parameter): self.attribute = parameter 或: class Example: def _init_(self, parameter): self.attribute = parameter 随后尝试创建类的实例时,发生错误: >>> Example("an argument") Traceback (most recent call last): File "", line 1, in TypeError: Example() takes no arguments 另外,该类的实例似乎缺少属性: >>> class Example: ... def __int__(self): # or _i
i有一个.gpx文件,该文件被切断了文件的中间.当我尝试使用 gpxpy库我遇到以下错误. 时, Parsing points in track.gpx ERROR:root:expected '>', line 3125, column 29 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gpxpy-0.8.7-py2.7.egg/gpxpy/parser.py", line 209, in parse self.xml_parser = LXMLParser(self.xml) File "/usr/local/lib/python2.7/dist-packages/gpxpy-0.8.7-py2.7.egg/gpxpy/parser.py", line 107, in __init__ self.dom = mod_etree.XML(sel
Newbie在这里 - 我的第一次尝试似乎还可以,但这是我对Pandas的第二次使用. 在Windows 7上使用Pandas 0.12.0时,我从SQL读取2个数据范围 一个人像预期的那样与Groupby一起使用,所以我敢肯定我的问题不是语法. 但是另一个地方,type(reddf)return pandas.core.frame.dataframe,尝试reddf.groupby('任何列')时 - 我得到的 - 最后几行 - c:\python27\lib\site-packages\pandas\core\groupby.pyc in __init__(self, index, grouper, name, level, sort) 1197 # no level passed 1198 if not isinstance(self.grouper, np.ndarray): -> 1199
我开始学习大熊猫,我正在遵循这个问题在这里,无法获得建议为我工作的解决方案,我会遇到索引错误.这就是我拥有的 from pandas import * import pandas as pd d = {'L1' : Series(['X','X','Z','X','Z','Y','Z','Y','Y',]), 'L2' : Series([1,2,1,3,2,1,3,2,3]), 'L3' : Series([50,100,15,200,10,1,20,10,100])} df = DataFrame(d) df.groupby('L1', as_index=False).apply(lambda x : pd.expanding_sum(x.sort('L3', ascending=False)['L3'])/x['L3'].sum()) 输出以下(我正在使用ipython) L1 X 3 0.571429 1 0.
因此,我从基本上更改了panda.frame. 但是,当我运行代码时,它可以正常工作直到某个点(我不确定发生错误时),并且它给了我typeError:必须是真实的数字,而不是str.与熊猫一起运行它的效果很好,没有任何错误,但只能与Polars一起使用.我知道它一定是使用错误的数据类型,但是我真的不知道我刚刚开始使用Python以来应该寻找的地方. 因此,如果有人可以帮助我,我真的很感激! thanx阅读,祝您有美好的一天! Traceback (most recent call last): File "C:\yolov5\test.py", line 61, in boxes = results.polars().xywh[0] File "c:\yolov5\.\models\common.py", line 684, in polars setattr(new, k, [pl.DataFrame(x, columns=c) for x in a
我一直在遇到错误:typeError:float()参数必须是字符串或数字,而不是"方法".以下是我的代码段. 我已经检查了其他帖子: typeError:float()参数必须是字符串或数字,而不是'函数' - python/sklearn ,但似乎无法达到错误的根本原因. Python说我的变量(y,x1,x2等)是"方法",这就是为什么我会收到错误? 如果是这样,有人知道我如何解决这个问题吗?事先感谢任何可以帮助我的人! # Replace inf and NaNs df_raw['daily pct return']= df_raw['daily pct return'].replace([np.inf, -np.inf],np.nan).dropna df_raw = pd.DataFrame(data=df_raw) df_raw.to_csv('Raw_final.csv', header=True) y = (df_raw['daily pct r
我正在尝试加入两个具有时间盖章行的数据范围.框架A由具有开始时间A1和结束时间A2的事件组成.框架B中的事件每个都只有一次. import pandas as pd import datetime as dt # Data df_A = pd.DataFrame({'A1': [dt.datetime(2017,1,5,9,8), dt.datetime(2017,1,5,9,9), dt.datetime(2017,1,7,9,19), dt.datetime(2017,1,7,9,19), dt.datetime(2017,1,7,9,19), dt.datetime(2017,2,7,9,19), dt.datetime(2017,2,7,9,19)], 'A2': [dt.datetime(2017,1,5,9,9), dt.datetime(2017,1,5,9,12), dt.datetime(2017,1,7
我有一个大数据框架.我想选择用于Machine1和Northamerica的数据.因此,如果Machine1和Northamerica在一排数据中,我想保留该行. 我知道如何做一个要求: df = df[df['MachineNumber'].isin(['Machine1'])] 工作完美,切成我需要的所有数据.但是,我不知道该如何做两件事. 我尝试进行两次,分别像这样: df = df[df['MachineNumber'].isin(['Machine1'])] df = df[df['Region'].isin(['NorthAmerica'])] 我也尝试了 df = df[(df['Region']=='NorthAmerica') & (df['MachineNumber']=='Machine1')] ,但两次尝试都丢弃了错误TypeError: unsupported type for add operation,它仅返回使用
我有一个pandas dataframe,其中有几个标志/虚拟变量Int64. 我在其他字段上汇总并采用平均值以计算百分比. df.groupby(["key1", "key2"]).mean() 当我尝试采取平均值时,我得到TypeError: cannot safely cast non-equivalent float64 to int64. 当我尝试一对一的每一列的平均值时,我不会收到错误. 我试图了解可能导致错误的原因.任何洞察力都将不胜感激. 这是数据的描述: In: df.info() Out: Int64Index: 6910491 entries, 82222 to 6858085 Data columns (total 5 columns): # Column Dtype --- ------ ----- 0 ke
我正在以JSON格式下载数据并将其保存到数据框架中. data = [] for day in range(9,10): request=Request('https://api..../10/'+str(day)+'/'+appId='+appID+') response = urlopen(request) arrivals = response.read() d = json.loads(arrivals) data.append(json_normalize(d['Statuses'])) data[column_names].to_csv("data.csv") 但是,此代码的最后一行提供了一个错误: TypeError: list indices must be integers, not list 看起来data是一个列表.我尝试了创建data,如下所示:data = pandas.
我运行了代码: df["VotesPerYear"] = df["Votes"]/df["Years"] 并收到错误: "TypeError: unsupported operand type(s) for /: 'unicode' and 'float'" df ["票数"]是一串数字,它们是千分之一的分离器.什么是将其转换为浮点的最佳方法是什么? 我可以执行操作? 解决方案 您可以使用df["VotesPerYear"] = df["Votes"].str.replace(",", "").astype(float) / df["Years"] 其他解决方案 如果df ['fotes']中的每个元素是u'x,xxx,xxx.xx'的形式,例如 我们可以做: df["VotesPerYear"] = df["Votes"].map(lambda x: float(''.join(x.split(',')))) / df["Years"
我有一个大约20列的数据框,我试图通过仅选择一些特定列来获取数据框的子集.6.我的代码行是: df3_query = df3[['Cont NUMBER'],['PL NUMBER'],['NAME'],['LOAN COUNT'],['SCORE MINIMUM'],['COUNT PERCENT']] 我遇到一个错误 TypeError: unhashable type: 'list' 我可以知道为什么我会遇到此错误的原因吗?另外,我只想从DF3 DataFrame中选择那些列.谁能帮助我? 解决方案 您需要在一个列表中写下列名,而不是列表: df3_query = df3[['Cont NUMBER', 'PL NUMBER', 'NAME', 'LOAN COUNT', 'SCORE MINIMUM', 'COUNT PERCENT']] 来自 docs : 您可以将列列表传递给[]以按此顺序选择列. 如果数据框中未包含列,
我有一个巨大的数据框架,我想使用dask处理,以节省时间.问题在于,我就开始运行后立即陷入此TypeError: can't pickle _thread._local objects错误.有人可以帮我吗? 我编写了一个基于其行中存储在DF中的数据的函数,然后用 对其进行处理 out = df_query.progress_apply(lambda row: run(row), axis=1) 它运行良好. 由于这需要很多时间,所以我开始使用dask: ddata = dd.from_pandas(df_query, npartitions=3) out = ddata.map_partitions(lambda df: df.apply((lambda row: run(row)), axis=1)).compute(scheduler='processes') 问题是,一旦处理开始,我就会得到此错误(在巨大的追溯之后,请参见下文):TypeError: