Hello
It seems like you want to partition your data into separate files based on the values in the "Branchid" and "date" columns. Below is an example of how you can achieve this using Python and pandas:
import pandas as pd data = {'Branchid': [1, 1, 2, 2], 'date': ['2021-09-01', '2022-10-01', '2021-09-01', '2022-10-01'], 'value': [10, 20, 30, 40]} df = pd.DataFrame(data) df['date'] = pd.to_datetime(df['date']) for (branch_id, year), group in df.groupby(['Branchid', df['date'].dt.year]): filename = f'file{branch_id}_{year}.ndf' group.to_csv(filename, index=False)
In this example, the code first converts the 'date' column to a datetime type. Then, it iterates through unique combinations of 'Branchid' and 'date.year'. For each combination, it creates a filename based on 'Branchid' and 'date.year' and saves the corresponding rows to a CSV file.
Make sure to adjust the column names and data according to your actual DataFrame structure.Refer thissource .
Thank you