wesm/pandas — Issue #290: DataFrame.to_csv throws exception
Author: dieterv77
Created: 2011-10-26 00:56:05+00:00
State: open

Hi, i ran into a problem with the current master on github. Here's

import cStringIO as StringIO
import pandas
f1 = StringIO.StringIO('a,1.0\nb,2.0')
df = pandas.DataFrame.from_csv(f1,header=None)
newdf = pandas.DataFrame({'t': df[df.columns[0]]})
newdf.to_csv('/tmp/test.csv')

The last line gives me an exception like this:

Traceback (most recent call last):
File "/tmp/test.py", line 6, in
newdf.to_csv('/tmp/test.csv')
File "/usr/lib/python2.7/dist-packages/pandas/core/frame.py", line 531, in to_csv
csvout.writerow(list(index_label) + list(cols))
TypeError: 'NoneType' object is not iterable

Code like this was working until quite recently. What i'm really trying to do is to read a bunch of csv files, each of which contains two columns of data, the first being the index, the second some values. The index is the same across files, so
i'm trying to combine these files into one DataFrame.

thanks
dieter