简体   繁体   English

TypeError:parse()接受1个位置参数,但给出了6个

[英]TypeError: parse() takes 1 positional argument but 6 were given

I am trying to run below code but everytime I am getting a typing error. 我正在尝试在代码下运行,但是每次遇到输入错误时,我都会这样做。

def parse(x):
    return datetime.strptime(x, '%Y %-m %-d %-H:%-M:%-S')

dataset = read_csv('ID1887011.csv', delimiter=",", parse_dates = [['year', 
'month','day','hours','minutes', 'seconds']], 
               index_col=0, date_parser=parse)

Hi I made some changes in the code and now its working. 嗨,我对代码进行了一些更改,现在可以正常工作了。

dataset = pd.read_csv('ID1887011.csv', delimiter=",", index_col='datetime', 
parse_dates = {'datetime': [1,2,3,4,5,6]}, date_parser=lambda x: 
pd.datetime.strptime(x, '%Y %m %d %H %M %S'))

错误代码

代码无错误

First image is error code and second is correct code. 第一个图像是错误代码,第二个是正确代码。 You don't need to change the code. 您无需更改代码。 In your code i think you import datetime instead you need to from datetime import datetime 在您的代码中,我认为您要导入datetime,而您需要从datetime导入datetime

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

相关问题 类型错误:fit() 需要 1 个位置参数,但给出了 3 个 - TypeError: fit() takes 1 positional argument but 3 were given 类型错误:readData() 需要 1 个位置参数,但给出了 2 个 - TypeError: readData() takes 1 positional argument but 2 were given TypeError: get() 接受 1 个位置参数,但给出了 2 个 - TypeError: get() takes 1 positional argument but 2 were given TypeError: echo() 接受 1 个位置参数,但给出了 2 个 - TypeError: echo() takes 1 positional argument but 2 were given TypeError: f() 接受 1 个位置参数,但给出了 2 个 - TypeError: f() takes 1 positional argument but 2 were given TypeError: function() 接受 1 个位置参数,但给出了 2 个 - TypeError: function() takes 1 positional argument but 2 were given 类型错误:wrapper() 采用 1 个位置参数,但给出了 2 个 - TypeError: wrapper() takes 1 positional argument but 2 were given TypeError:done()接受1个位置参数,但给出了2个 - TypeError: done() takes 1 positional argument but 2 were given TypeError:isnull()接受1个位置参数,但给出了2个 - TypeError: isnull() takes 1 positional argument but 2 were given TypeError: start() 接受 1 个位置参数,但给出了 2 个 - TypeError : start() takes 1 positional argument but 2 were given
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM