Skip to content

DataFrame corrupted after improper column creation #3010

Closed
@zetyang

Description

@zetyang

I want to add a column to DataFrame using a list of arrays, but I forgot to change the 2d array into list first, so I got a "Wrong number of items passed" error.

After that, the df seemed to be corrupted, whenever I want to print it, it kept raising a "NoneType object is not iterable error".
While it could still be added new columns, the improperly assigned columns couldn't be deleted yet (also prompting the NoneType error).

This the code that could reproduce my problem:

df = DataFrame(np.ones((4,4)))
df['foo'] = np.ones((4,2)).tolist()  # OK, and that's what I should type
df['test'] = np.ones((4,2))  # the improper column creation
AsssertionError: Wrong number of items passed1 vs 2)

df
TypeError: 'NoneType' object is not iterable, u'occured at index foo'

del df['test']
TypeError: 'NoneType' object is not iterable

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