Skip to content

API/REGRESS: partial revert of f8b6208675b5b10d73a74f50478fa5e37b43fc02 (GH5720,GH5744) #5747

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

Merged
merged 1 commit into from
Dec 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,10 +1916,11 @@ def _ensure_valid_index(self, value):
'Series')
self._data.set_axis(1, value.index.copy(), check_axis=False)

# we are a scalar
# noop
else:
raise ValueError('Cannot set a frame with no defined index '
'and a value that cannot be converted to a '
'Series')

pass

def _set_item(self, key, value):
"""
Expand Down
10 changes: 4 additions & 6 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,14 +1778,12 @@ def f():
# don't create rows when empty
df = DataFrame({"A": [1, 2, 3], "B": [1.2, 4.2, 5.2]})
y = df[df.A > 5]
def f():
y['New'] = np.nan
self.assertRaises(ValueError, f)
y['New'] = np.nan
assert_frame_equal(y,DataFrame(columns=['A','B','New']))

df = DataFrame(columns=['a', 'b', 'c c'])
def f():
df['d'] = 3
self.assertRaises(ValueError, f)
df['d'] = 3
assert_frame_equal(df,DataFrame(columns=['a','b','c c','d']))
assert_series_equal(df['c c'],Series(name='c c',dtype=object))

# reindex columns is ok
Expand Down