类型错误:';非类型';对象在python函数中不可编辑
我写了以下代码:类型错误:';非类型';对象在python函数中不可编辑,python,dataframe,counter,Python,Dataframe,Counter,我写了以下代码: def summarize_withoutStations(path, month): calculate_withoutStations(getFiles(path, month)) def calculate_stations (allFiles): result = pd.DataFrame(columns = ['Date','Mid Ebb Total','Mid Flood Total','Mid Ebb Control','Mid Flood
def summarize_withoutStations(path, month):
calculate_withoutStations(getFiles(path, month))
def calculate_stations (allFiles):
result = pd.DataFrame(columns = ['Date','Mid Ebb Total','Mid Flood Total','Mid Ebb Control','Mid Flood Control'])
Mid_Ebb_unique_stations = []
Mid_Flood_unique_stations = []
for file_ in allFiles:
print('Checking' +str(file_))
xls = pd.ExcelFile(file_)
df = xls.parse('General Impact')
if len(df) > 300:
print('Please check if there are more than one month data in the excel')
cont = input('Please type Y to continue, N to exit')
if cont == 'Y':
continue
if cont == 'N':
break
Mid_Ebb = df[df['Tidal Mode'] == "Mid-Ebb"] #filter
Mid_Flood = df[df['Tidal Mode'] == "Mid-Flood"] #filter
Mid_Ebb_stations = Mid_Ebb['Station'].unique()
Mid_Flood_stations = Mid_Flood['Station'].unique()
Mid_Ebb_unique_stations.extend(list(Mid_Ebb_stations))
Mid_Flood_unique_stations.extend(list(Mid_Flood_stations))
Ebb_list = Counter(Mid_Ebb_unique_stations)
Flood_list = Counter(Mid_Flood_unique_stations)
total_Mid_Ebb = sum(Ebb_list.values())
total_Mid_Flood = sum(Flood_list.values())
print('Ebb tide list: ' + str(Ebb_list))
print('Flood tide list:' + str(Flood_list))
print('Ebb tide total: {} Flood totaltide: {}'.format(total_Mid_Ebb, total_Mid_Flood))
df_Ebb_list = pd.DataFrame.from_dict(Ebb_list, orient='index')
df_Flood_list = pd.DataFrame.from_dict(Flood_list, orient='index')
print(df_Ebb_list)
print(df_Flood_list)
return df_Ebb_list, df_Flood_list
当我调用
a,b=func.summary\u with stations(path,month)
时,它给出了TypeError:“NoneType”对象是不可编辑的
数据帧也不打印。我做了一些愚蠢的事情
def summarize_withoutStations(path, month):
calculate_withoutStations(getFiles(path, month))
没有返回语句。它在哪一行出错?也请阅读:.a,b=func.summary_with stations(path,month)当我以非函数方式(逐个检查文件)进行汇总时,我可以获得数据帧(df_Ebb_list和df_Flood_list),您可以发布完整的回溯吗。此函数中将有一行出现故障,请阅读并不要忽略: