import pandas as pd def hebing(): # read the Excel file df = pd.read_excel('../datas/duihua.xlsx', sheet_name='Sheet2') # group the rows into chunks of 100 chunks = [df[i:i + 100] for i in range(0, len(df), 100)] # concatenate the text column of each chunk into a single row merged_chunks = [chunk['合并咨询文本'].str.cat(sep=' ') for chunk in chunks] # create a new dataframe with the merged chunks new_df = pd.DataFrame({'合并咨询文本': merged_chunks}) print(new_df) # write the new dataframe to a new Excel file new_df.to_excel('../datas/hebing.xlsx', index=False) hebing()