今天第一次用groupby
# -*- coding: utf-8 -*- """ Created on Mon Nov 03 18:27:22 2014 @author: Luo Hao at Tubic """ import pandas as pd if __name__ == '__main__': df = pd.read_table('degannotation-p.dat') a = df['#Gene_Ref'].groupby(df['#Organism']) for item in a: with open(item[0]+'.txt', 'w') as f: for i in item[1]: print >> f, i
就是想分类输出GI号。