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] Cannot insert a cudf.NA into a DataFrame #8922

Closed
sarahyurick opened this issue Aug 2, 2021 · 0 comments · Fixed by #8923
Closed

[BUG] Cannot insert a cudf.NA into a DataFrame #8922

sarahyurick opened this issue Aug 2, 2021 · 0 comments · Fixed by #8923
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@sarahyurick
Copy link
Contributor

sarahyurick commented Aug 2, 2021

In Pandas, I can do the following:

import pandas as pd
x = pd.DataFrame({'a':[1,2,3]})
x['b'] = pd.NA
x
   a     b
0  1  <NA>
1  2  <NA>
2  3  <NA>

However, with cuDF I get the following error:

import cudf
x = cudf.DataFrame({'a':[1,2,3]})
x['b'] = cudf.NA
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_33816/3347028048.py in <module>
      1 import pandas as pd
      2 
----> 3 x['b'] = cudf.NA

~/miniconda3/envs/cudf_dev/lib/python3.8/contextlib.py in inner(*args, **kwds)
     73         def inner(*args, **kwds):
     74             with self._recreate_cm():
---> 75                 return func(*args, **kwds)
     76         return inner
     77 

~/miniconda3/envs/cudf_dev/lib/python3.8/site-packages/cudf/core/dataframe.py in __setitem__(self, arg, value)
    764                     # disc. with pandas here
    765                     # pandas raises key error here
--> 766                     self.insert(len(self._data), arg, value)
    767 
    768         elif can_convert_to_column(arg):

~/miniconda3/envs/cudf_dev/lib/python3.8/contextlib.py in inner(*args, **kwds)
     73         def inner(*args, **kwds):
     74             with self._recreate_cm():
---> 75                 return func(*args, **kwds)
     76         return inner
     77 

~/miniconda3/envs/cudf_dev/lib/python3.8/site-packages/cudf/core/dataframe.py in insert(self, loc, name, value)
   3080 
   3081         if _is_scalar_or_zero_d_array(value):
-> 3082             value = utils.scalar_broadcast_to(value, len(self))
   3083 
   3084         if len(self) == 0:

~/miniconda3/envs/cudf_dev/lib/python3.8/site-packages/cudf/utils/utils.py in scalar_broadcast_to(scalar, size, dtype)
     69 
     70     scalar = to_cudf_compatible_scalar(scalar, dtype=dtype)
---> 71     dtype = scalar.dtype
     72 
     73     if np.dtype(dtype).kind in ("O", "U"):

AttributeError: 'NAType' object has no attribute 'dtype'
@sarahyurick sarahyurick added bug Something isn't working Python Affects Python cuDF API. labels Aug 2, 2021
@sarahyurick sarahyurick self-assigned this Aug 2, 2021
@sarahyurick sarahyurick changed the title [BUG] Cannot insert an NA into a DataFrame [BUG] Cannot insert a cudf.NA into a DataFrame Aug 2, 2021
@galipremsagar galipremsagar linked a pull request Aug 2, 2021 that will close this issue
@rapids-bot rapids-bot bot closed this as completed in #8923 Aug 2, 2021
rapids-bot bot pushed a commit that referenced this issue Aug 2, 2021
Addressing #8922 - just have to check if it's a `cudf.NA` and set to `None` if necessary.

Authors:
  - Sarah Yurick (https://github.com/sarahyurick)

Approvers:
  - https://github.com/brandon-b-miller
  - Ram (Ramakrishna Prabhu) (https://github.com/rgsl888prabhu)

URL: #8923
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant