Skip to content
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

bug in DataFrame._set_index when the value is MultiIndex #3952

Open
ajpotts opened this issue Dec 27, 2024 · 0 comments
Open

bug in DataFrame._set_index when the value is MultiIndex #3952

ajpotts opened this issue Dec 27, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ajpotts
Copy link
Contributor

ajpotts commented Dec 27, 2024

See the example:

size = 10**8


arrays = [(np.arange(size)//2).tolist(), np.arange(size).tolist(),]

tuples = list(zip(*arrays))

tuples


index = pd.MultiIndex.from_tuples(tuples, names=["first", "second"])


s = pd.Series(np.random.randn(size), index=index)
s


df = s.to_frame()

Results in:

In [7]: ak.DataFrame(df)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/git/arkouda/arkouda/pdarraycreation.py:279, in array(a, dtype, max_bits)
    278 while any(a != 0) and len(uint_arrays) < early_out:
--> 279     low, a = a % 2**64, a // 2**64
    280     uint_arrays.append(array(np.array(low, dtype=np.uint), dtype=akuint64))

TypeError: unsupported operand type(s) for %: 'tuple' and 'int'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
Cell In[7], line 1
----> 1 ak.DataFrame(df)

File ~/git/arkouda/arkouda/dataframe.py:928, in DataFrame.__init__(self, initialdata, index, columns)
    925 self._columns = initialdata.columns.tolist()
    927 if index is None:
--> 928     self._set_index(initialdata.index)
    929 else:
    930     self._set_index(index)

File ~/git/arkouda/arkouda/dataframe.py:1891, in DataFrame._set_index(self, value)
   1889     self._index = value
   1890 elif isinstance(value, (pdarray, Strings, pd.Index)):
-> 1891     self._index = Index(value)
   1892 elif isinstance(value, list):
   1893     self._index = Index(array(value))

File ~/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/typeguard/__init__.py:891, in typechecked.<locals>.wrapper(*args, **kwargs)
    889 memo = _CallMemo(python_func, _localns, args=args, kwargs=kwargs)
    890 check_argument_types(memo)
--> 891 retval = func(*args, **kwargs)
    892 check_return_type(retval, memo)
    894 # If a generator is returned, wrap it if its yield/send/return types can be checked

File ~/git/arkouda/arkouda/index.py:93, in Index.__init__(self, values, name, allow_list, max_list_size)
     91     self.values = Categorical(values.values)
     92 else:
---> 93     self.values = array(values.values)
     94 self.size = values.size
     95 self.dtype = self.values.dtype

File ~/git/arkouda/arkouda/pdarraycreation.py:283, in array(a, dtype, max_bits)
    281         return bigint_from_uint_arrays(uint_arrays[::-1], max_bits=max_bits)
    282     except TypeError:
--> 283         raise RuntimeError(f"Unhandled dtype {a.dtype}")
    284 else:
    285     from arkouda.util import _infer_shape_from_size

RuntimeError: Unhandled dtype object



@ajpotts ajpotts added the bug Something isn't working label Dec 27, 2024
@ajpotts ajpotts self-assigned this Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant