I wonder if is it possible to save data from one df in parts as many individual csv files? The part of my input df looks like that:
df_unique_final_1_idx sample condition
0 0 P1-12 one_one
1 0 P1-25 one_one
2 0 P1-28 one_one
3 0 P1-22 zero_zero
4 0 P1-89 zero_zero
5 0 P1-92 zero_zero
6 1 P1-12 one_one
7 1 P1-90 one_one
8 1 P1-95 one_one
9 1 P1-26 zero_zero
10 1 P1-88 zero_zero
11 1 P1-92 zero_zero
I need to prepare individual tab-delimited csv files as the input for further pipeline for every set of samples and conditions with the same df_unique_final_1_idx
value. In the first hashable line of every csv file should be df_unique_final_1_idx
value and in the second one - the column header. The desired output of a single csv file for df_unique_final_1_idx
value = 0 should look like that:
#0
#sample condition
P1-12 one_one
P1-25 one_one
P1-28 one_one
P1-22 zero_zero
P1-89 zero_zero
P1-92 zero_zero
Is it possible to do it with any loop? I have hundreds of individual files to prepare so I'll be very grateful for help!