这是什么意思? AttributeError:“工作表”对象没有“工作表”属性 这个错误出现在我运行代码时,我无法理解它的含义。你知道吗
整个错误是:
2 Jan = Jan.worksheet('01')
----> 3 while Jan.worksheet() != 31:
4 Jan = get_as_dataframe(Jan)
5 Jan = pd.DataFrame(Jan)
AttributeError:“工作表”对象没有“工作表”属性
How to write a python for loop to reformat 31 different google sheets with pandas 这是同一代码下另一个问题的链接。你知道吗
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)
我只需要知道如何在我的代码修复这个问题,如果有人也可以解决我的其他代码问题,那将不胜感激。你知道吗
这个错误告诉您某处有一个
Workbook
对象,您正试图访问它的worksheet
属性,即Worksheet.worksheet
。但是,Worksheet
没有属性worksheet
可以访问。你知道吗错误只会告诉你什么是错误的。剩下的回溯告诉你哪里是错的。我的猜测是错误中引用的对象是
Jan
。如果你提供剩下的追踪,我们中的一个可能会肯定地告诉你。你知道吗相关问题 更多 >
编程相关推荐