You can add in csv opening the file in add mode:
with open('my_csv.csv', 'a') as f: df.to_csv(f, header=False)
If it was your csv, foo.csv :
,A,B,C 0,1,2,3 1,4,5,6
If you read this, then add, for example, df + 6 :
In [1]: df = pd.read_csv('foo.csv', index_col=0) In [2]: df Out[2]: ABC 0 1 2 3 1 4 5 6 In [3]: df + 6 Out[3]: ABC 0 7 8 9 1 10 11 12 In [4]: with open('foo.csv', 'a') as f: (df + 6).to_csv(f, header=False)
foo.csv becomes:
,A,B,C 0,1,2,3 1,4,5,6 0,7,8,9 1,10,11,12
Andy Hayden Jul 08 '13 at 15:57 2013-07-08 15:57
source share