Skip to content

DataFrame.to_csv throws exception #290

@dieterv77

Description

@dieterv77

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions