[英]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.