How can I modify this code?
I have a lot of data, including several columns that the data ID are sorted from low to high and the columns are separated by (;) and are arranged. , and I want each row that contains the ID name to be saved as a separate CSV file with the same ID name. I wrote a part of the code in Jupyter Notebook, but when the name of the ID changes, the program continues to save with the same ID, the previous one. Currently, all rows are stored as 900440_1, 900440_2 and so on.And I want them saved that way: 900440_1,900440_2,900440_900660_1,... The data is as follows: ID Name Date Time Head 900440 A 01.04.2013 00:00:00 250.98 900440 B 01.04.2013 01:00:00 250.98 900440 C 01.04.2013 02:00:00 250.99 . . . 900660 D 01.04.2013 03:00:00 250.99 900660 E 01.04.2013 04:00:00 240.99 900660 F 01.04.2013 05:00:00 260.99 . . . 900770 I 01.04.2013 04:00:00 250.99 900770 J 01.04.2013 05:00:00 251.00 900770 K 01.04.2013 06:00:00 251.00 . . . My code : i = 0 for row in range(len(data)): tmp= data.iloc[[row]] tmp.to_csv(r'C:\Users\IMAN\data\900440_%s.csv'%str(row))