-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DataFrame corrupted after improper column creation #3010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You realize you are creating an embedded list (what you are assigning to
|
Yes, you're right, I know your way does work and I should do that way. My point is that I wrongly assigned the column, and then realized that I made a mistake. When I went on my work, DataFrame corrupted. I used to thought that DataFrame would be robust to my mistake. |
In [1]: df._data.items
Out[1]: [0,1,2,3,'foo', 'test']
loc = df._data.get_loc('test')
new_items = df._data.items.delete(loc)
df._data.set_items_norename(new_items) Above lines could finally fix my problem (after refering to the source code in core/internals.py ). The problem is due to that the data block corresponding to But I still wonder why DataFrame add the item |
see PR #3018, essentially the insertion operation is 2 stages, if the first fails then the state of th existing thanks for the report. |
My pleasure, btw, pandas is really awesome :-) |
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:
The text was updated successfully, but these errors were encountered: