这是什么意思? AttributeError:“工作表”对象没有属性“工作表” 当我运行我的代码时出现此错误,但我不知道这意味着什么。
整个错误是:
2 Jan = Jan.worksheet('01')
----> 3 while Jan.worksheet() != 31:
4 Jan = get_as_dataframe(Jan)
5 Jan = pd.DataFrame(Jan)
AttributeError:“工作表”对象没有属性“工作表”
Jan = gc.open_by_url('with held for privacy reasons')
Jan = Jan.worksheet('01')
#for worksheet in Jan.worksheet:
#while Jan.worksheet is not 31:
if Jan.worksheet != 31:
Jan = get_as_dataframe(Jan)
Jan = pd.DataFrame(Jan)
day_month = Jan.worksheet
new_header = Jan.iloc[0]
Jan = Jan[1:]
Jan.columns = new_header
col_list = ['Time', 'Roof(in)', 'East(in)', 'West(in)', 'North(in)', 'Roof(out)', 'East(out)', 'West(out)', 'North(out)']
Jan = Jan[col_list]
Jan = Jan.dropna(axis=0, how='all')
Jan = Jan[:-2]
Jan.columns = ['DateTime', 'Business_Location_In', 'East_Location_In', 'West_Location_In', 'North_Location_In',
'Business_Location_Out', 'East_Location_Out', 'West_Location_Out', 'North_Location_Out']
Jan['DateTime'] = Jan['DateTime'].str.slice(6)
Jan['DateTime'] = pd.to_datetime('2019-01- ' + worksheet+ Jan['DateTime'])
for filename in Jan:
Jan['Jan'+ day_month] = filenames
while Jan.worksheet() < 31:
Jan = Jan.worksheet(day_month + 1)
elif Jan.worksheet == 31:
Jan = get_as_dataframe(Jan)
Jan = pd.DataFrame(Jan)
day_month = Jan.worksheet
new_header = Jan.iloc[0]
Jan = Jan[1:]
Jan.columns = new_header
col_list = ['Time', 'Roof(in)', 'East(in)', 'West(in)', 'North(in)', 'Roof(out)', 'East(out)', 'West(out)', 'North(out)']
Jan = Jan[col_list]
Jan = Jan.dropna(axis=0, how='all')
Jan = Jan[:-2]
Jan.columns = ['DateTime', 'Business_Location_In', 'East_Location_In', 'West_Location_In', 'North_Location_In',
'Business_Location_Out', 'East_Location_Out', 'West_Location_Out', 'North_Location_Out']
Jan['DateTime'] = Jan['DateTime'].str.slice(6)
Jan['DateTime'] = pd.to_datetime('2019-01- ' + worksheet+ Jan['DateTime'])
for filename in Jan: #this sets the file name to Jan and the day of month
Jan['Jan'+ day_month] = filenames
print(filenames)
我只需要知道如何在我的代码中解决此问题,并且如果有人也可以解决我的其他代码问题,那将不胜感激。
答案 0 :(得分:3)
该错误告诉您在某个地方有一个Workbook
对象,并且您正在尝试访问其worksheet
属性,即Worksheet.worksheet
。但是,Worksheet
不能使用worksheet
来装饰。
该错误仅告诉您什么错误。其余的回溯告诉您哪里这是错误的。我的猜测是错误中引用的对象是Jan
。如果您提供其余的回溯,那么我们中的一位可能可以肯定地告诉您。