diff --git a/pandas/core/internals.py b/pandas/core/internals.py index cbd1ccfabdeb7..fa1bfa0884045 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -1116,7 +1116,7 @@ def form_blocks(data, axes): blocks.append(float_block) if len(complex_dict): - complex_block = _simple_blockify(complex_dict, items, np.complex64) + complex_block = _simple_blockify(complex_dict, items, np.complex128) blocks.append(complex_block) if len(int_dict): @@ -1222,7 +1222,7 @@ def _interleaved_dtype(blocks): elif have_dt64 and not have_float and not have_complex: return np.datetime64 elif have_complex: - return np.complex64 + return np.complex128 else: return np.float64 diff --git a/pandas/src/inference.pyx b/pandas/src/inference.pyx index 6c88d293106ab..f6221cbddfa8c 100644 --- a/pandas/src/inference.pyx +++ b/pandas/src/inference.pyx @@ -11,7 +11,7 @@ _TYPE_MAP = { np.uint64: 'integer', np.float32: 'floating', np.float64: 'floating', - np.complex64: 'complex', + np.complex128: 'complex', np.complex128: 'complex', np.string_: 'string', np.unicode_: 'unicode', @@ -223,7 +223,7 @@ def maybe_convert_numeric(ndarray[object] values, set na_values): cdef: Py_ssize_t i, n ndarray[float64_t] floats - ndarray[complex64_t] complexes + ndarray[complex128_t] complexes ndarray[int64_t] ints bint seen_float = 0 bint seen_complex = 0 @@ -233,7 +233,7 @@ def maybe_convert_numeric(ndarray[object] values, set na_values): n = len(values) floats = np.empty(n, dtype='f8') - complexes = np.empty(n, dtype='c8') + complexes = np.empty(n, dtype='c16') ints = np.empty(n, dtype='i8') for i from 0 <= i < n: @@ -278,7 +278,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0, cdef: Py_ssize_t i, n ndarray[float64_t] floats - ndarray[complex64_t] complexes + ndarray[complex128_t] complexes ndarray[int64_t] ints ndarray[uint8_t] bools bint seen_float = 0 @@ -293,7 +293,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0, n = len(objects) floats = np.empty(n, dtype='f8') - complexes = np.empty(n, dtype='c8') + complexes = np.empty(n, dtype='c16') ints = np.empty(n, dtype='i8') bools = np.empty(n, dtype=np.uint8) diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index 0b353ea8eba73..1e554a663cff7 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -1691,7 +1691,7 @@ def test_constructor_scalar_inference(self): self.assert_(df['int'].dtype == np.int64) self.assert_(df['bool'].dtype == np.bool_) self.assert_(df['float'].dtype == np.float64) - self.assert_(df['complex'].dtype == np.complex64) + self.assert_(df['complex'].dtype == np.complex128) self.assert_(df['object'].dtype == np.object_) def test_constructor_DataFrame(self): diff --git a/pandas/tests/test_internals.py b/pandas/tests/test_internals.py index 976b4439fffdf..cf1ce851a6bfb 100644 --- a/pandas/tests/test_internals.py +++ b/pandas/tests/test_internals.py @@ -27,7 +27,7 @@ def get_float_ex(cols=['a', 'c', 'e']): return make_block(floats, cols, TEST_COLS) def get_complex_ex(cols=['h']): - complexes = (get_float_mat(N, 1).T * 1j).astype(np.complex64) + complexes = (get_float_mat(N, 1).T * 1j).astype(np.complex128) return make_block(complexes, cols, TEST_COLS) def get_obj_ex(cols=['b', 'd']): @@ -211,7 +211,7 @@ def test_block_id_vector_item_dtypes(self): result = self.mgr.item_dtypes expected = ['float64', 'object', 'float64', 'object', 'float64', - 'bool', 'int64', 'complex64'] + 'bool', 'int64', 'complex128'] self.assert_(np.array_equal(result, expected)) def test_union_block_items(self):