Skip to content

BUG/REG: fix float64index -> mixed float assignment #7368

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
Jun 6, 2014
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
3 changes: 3 additions & 0 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ Bug Fixes
- Bug all ``StringMethods`` now work on empty Series (:issue:`7242`)
- Fix delegation of `read_sql` to `read_sql_query` when query does not contain
'select' (:issue:`7324`).
- Bug where a string column name assignment to a ``DataFrame`` with a
``Float64Index`` raised a ``TypeError`` during a call to ``np.isnan``
(:issue:`7366`).
13 changes: 8 additions & 5 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2060,11 +2060,14 @@ def __contains__(self, other):
return False

def get_loc(self, key):
if np.isnan(key):
try:
return self._nan_idxs.item()
except ValueError:
return self._nan_idxs
try:
if np.isnan(key):
try:
return self._nan_idxs.item()
except ValueError:
return self._nan_idxs
except (TypeError, NotImplementedError):
pass
return super(Float64Index, self).get_loc(key)

@property
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,16 @@ def f():

warnings.filterwarnings(action='ignore', category=FutureWarning)

def test_float_index_to_mixed(self):
df = DataFrame({0.0: np.random.rand(10),
1.0: np.random.rand(10)})
df['a'] = 10
tm.assert_frame_equal(DataFrame({0.0: df[0.0],
1.0: df[1.0],
'a': [10] * 10}),
df)


if __name__ == '__main__':
import nose
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
Expand Down