I have two columns in excel sheet that looks like this
I want to iterate in python (using dataframe if possible) to produce multiple excel sheets where my excel files would look like this
File_1 Output (Column 1 will get 10 cities, column 2 will have all persons)
File_2 Output (Column 1 will get the next 10 cities, column 2 will have all persons without any change)
The for loop will continue to iterate until all the rows are done.Let's say if I have 105 cities in column 1, the code will generate 11 output files where the last file will only have 5 cities in column 1.
I have tried to use the following code
rows_per_file = 10n_chunks = PC // rows_per_filefor i in range(n_chunks): start = i*rows_per_file stop = (i+1) * rows_per_file sub_df= df(df.iloc[start:stop,0],0) sub_df2=df(df.iloc[0:UC,1],1) sub_df3= sub_df+sub_df2 sub_df3.to_excel(f"test-{i}.xlsx", sheet_name="sheet")
But it gives me all data in single column and slices my 2nd column to 10 person too instead of all 26 person.I have tried different ways but haven't been able to figure out.
Any help is appreciated :)