I made a random table and I want to transfer it to pivot tables, using define a function and also for loop. And I want to make the code reusable and automatically.
CodePudding user response:
Read the file in pandas. See the documentation on read_excel and read_csv
Then,
df = pd.set_index(['Date', 'State', 'Name').unstack()
df
Then you can write df to to another excel or csv file.

