You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "/usr/local/lib/python3.2/dist-packages/pandas-0.13.0rc1-py3.2-linux-x86_64.egg/pandas/core/frame.py", line 1855, in __setitem__
self._set_item(key, value)
File "/usr/local/lib/python3.2/dist-packages/pandas-0.13.0rc1-py3.2-linux-x86_64.egg/pandas/core/frame.py", line 1915, in _set_item
self._ensure_valid_index(value)
File "/usr/local/lib/python3.2/dist-packages/pandas-0.13.0rc1-py3.2-linux-x86_64.egg/pandas/core/frame.py", line 1899, in _ensure_valid_index
raise ValueError('Cannot set a frame with no defined index '
ValueError: Cannot set a frame with no defined index and a non-series
I stumbled upon it because I do a merge and then create a new column which is a copy of the index (for further manipulation). Sometimes that merge leaves me with an empty DataFrame.
More generally, I might want to create an auto-numbered column with df['foo'] = range(len(df)). With the recent code change, I either have to change that to df['foo'] = pd.Series(range(len(df))) or do a check to ensure that df is not empty.
you don't need to auto number
the index if you don't set it IS an auto numbered index (and if u have a different index, you can just df.reset_index())
no need to actually have a numbering
This issue appears in 0.13.0-rc1 and did not appear in 0.12.0-854-gde63e00
Let us say we have an empty DataFrame. Then the following calls (which worked in pandas 0.12) no longer work:
They all throw an exception:
The following will work:
The issue appears to be on lines 1897-1899 of pandas.core.frame:
Perhaps it could be changed to:
The text was updated successfully, but these errors were encountered: