I used the following to get proportion information on my data:
>>>testfile = pd.read_csv('CCCC_output_all_FINAL.txt', delimiter="\t", header=0)
>>> testdf = pd.DataFrame({'Proportion': testfile.groupby(('Name','Chr','Position','State')).size() / 39})
>>> testdf.head(5)
Proportion
Name Chr Position State
S-3AAAA 16 27557749 4 0.025641
5 0.076923
6 0.025641
S-3AAAC 15 35061490 2 0.076923
4 0.025641
>>> testdf.to_csv('CCCC_output_summary.txt', sep='\t', header=True, index=False)
The output file only has the column Proportion
. I'd like the following table output:
Name Chr Position State Proportion
S-3AAAA 16 27557749 4 0.025641
S-3AAAA 16 27557749 5 0.076923
S-3AAAA 16 27557749 6 0.025641
S-3AAAC 15 35061490 2 0.076923
S-3AAAC 15 35061490 4 0.025641
Is it possible/easy to write the pandas output to a file like this?