简体   繁体   English

TypeError: append() 从 2 到 5 个位置 arguments 但给出了 8 个

[英]TypeError: append() takes from 2 to 5 positional arguments but 8 were given

I am trying to create a for loop that will iterate operations for some files.我正在尝试创建一个 for 循环来迭代某些文件的操作。 The for loop works just fine until it arrives at the append operation. for 循环工作得很好,直到它到达 append 操作。 It gives me the following error:它给了我以下错误:

TypeError: append() takes from 2 to 5 positional arguments but 8 were given TypeError: append() 从 2 到 5 个位置 arguments 但给出了 8 个

How is it possible to fix this?怎么可能解决这个问题?

>>> index = 0

>>> for value in Sample:
...     data = read_file(value)
...     #operations 
...     #operations
...     #operations
...     Data =pd.DataFrame([[Car_Model, Car_Length, Car_Width, Car_Height, Car_Engine, Manufactured_Year, Purchased_Year]], columns=['Car_Model', 'Car_Length', 'Car_Width', 'Car_Height', 'Car_Engine', 'Manufactured_Year', 'Purchased_Year']) 
...     Data.append(Car_Model, Car_Length, Car_Width, Car_Height, Car_Engine, Manufactured_Year, Purchased_Year)
...     index += 1

From the documentation of DataFrame.append ( link ):DataFrame.append的文档( 链接):

DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=False)

As you can see it expects 5 parameters.如您所见,它需要 5 个参数。 You are giving 8, which is too much and which is also stated in your error.您给 8,这太多了,您的错误中也说明了这一点。

The elements to be appended are in the parameter other which has this description:要附加的元素在具有以下描述的参数other中:

other : DataFrame or Series/dict-like object, or list of these其他:DataFrame 或 Series/dict-like object,或这些列表

The data to append.数据到 append。

Warning : The documentation also says that append is deprecated:警告:文档还说append已被弃用:

Deprecated since version 1.4.0: Use concat() instead. 1.4.0 版后已弃用:改用 concat()。 For further details see Deprecated DataFrame.append and Series.append有关详细信息,请参阅弃用的 DataFrame.append 和 Series.append

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:raw_input() 需要 1 到 2 个位置参数,但给出了 4 个 - TypeError: raw_input() takes from 1 to 2 positional arguments but 4 were given Django TypeError:url()需要2到4个位置参数,但是给出了16个 - Django TypeError: url() takes from 2 to 4 positional arguments but 16 were given 继承 TypeError: __init__() 接受 1 到 2 个位置参数,但给出了 8 个 - inheritance TypeError: __init__() takes from 1 to 2 positional arguments but 8 were given TypeError: with_column() 从 3 到 4 个位置 arguments 但给出了 5 个(python) - TypeError: with_column() takes from 3 to 4 positional arguments but 5 were given (python) Tkinter | TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given - Tkinter | TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given Python: TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given - Python : TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given 类型错误:__call__() 需要 1 到 2 个位置参数,但给出了 3 个 - TypeError: __call__() takes from 1 to 2 positional arguments but 3 were given TypeError:__init __()从1到2个位置参数,但给出了3个 - TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given TypeError:match()接受2到3个位置参数,但给出了5个 - TypeError: match() takes from 2 to 3 positional arguments but 5 were given TypeError:update()接受1到2个位置参数,但给出了3个。 - TypeError : update() takes from 1 to 2 positional arguments but 3 were given.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM