Skip to content

"df.get(None)" throws error in 0.13 -> regression? #5652

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

Closed
jankatins opened this issue Dec 6, 2013 · 10 comments · Fixed by #6053
Closed

"df.get(None)" throws error in 0.13 -> regression? #5652

jankatins opened this issue Dec 6, 2013 · 10 comments · Fixed by #6053
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jankatins
Copy link
Contributor

This works with pandas 0.12:

from ggplot import meat
meat.get(None)
[returns None]

But throws an error in 0.13 (RC):

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-86be6a7317b8> in <module>()
----> 1 meat.get(None)

C:\portabel\Python27\lib\site-packages\pandas\core\generic.pyc in get(self, key, default)
    961         """
    962         try:
--> 963             return self[key]
    964         except KeyError:
    965             return default

C:\portabel\Python27\lib\site-packages\pandas\core\frame.pyc in __getitem__(self, key)
   1626             return self._getitem_multilevel(key)
   1627         else:
-> 1628             return self._getitem_column(key)
   1629 
   1630     def _getitem_column(self, key):

C:\portabel\Python27\lib\site-packages\pandas\core\frame.pyc in _getitem_column(self, key)
   1633         # get column
   1634         if self.columns.is_unique:
-> 1635             return self._get_item_cache(key)
   1636 
   1637         # duplicate columns & possible reduce dimensionaility

C:\portabel\Python27\lib\site-packages\pandas\core\generic.pyc in _get_item_cache(self, item)
    972         res = cache.get(item)
    973         if res is None:
--> 974             values = self._data.get(item)
    975             res = self._box_item_values(item, values)
    976             cache[item] = res

C:\portabel\Python27\lib\site-packages\pandas\core\internals.pyc in get(self, item)
   2737             if isnull(item):
   2738                 indexer = np.arange(len(self.items))[isnull(self.items)]
-> 2739                 return self.get_for_nan_indexer(indexer)
   2740 
   2741             _, block = self._find_block(item)

C:\portabel\Python27\lib\site-packages\pandas\core\internals.pyc in get_for_nan_indexer(self, indexer)
   2789                 indexer = indexer.item()
   2790             else:
-> 2791                 raise ValueError("cannot label index with a null key")
   2792 
   2793         # take a nan indexer and return the values

ValueError: cannot label index with a null key

Not sure if that is intentional as this broke some code in the facet_wrap in ggplot (which now will get some update against this :-) )

@jreback
Copy link
Contributor

jreback commented Dec 6, 2013

that seems like a very odd thing to do as its trying to get something indexed by None

@ghost
Copy link

ghost commented Jan 23, 2014

@jreback , close as wontfix? this looks like reasonable behavior to me

@jreback
Copy link
Contributor

jreback commented Jan 23, 2014

what is meat? a sub-class of frame?

@jreback
Copy link
Contributor

jreback commented Jan 23, 2014

?

In [62]: DataFrame().get(None)
ValueError: cannot label index with a null key

@jreback
Copy link
Contributor

jreback commented Jan 23, 2014

easy to fix I think

@ghost
Copy link

ghost commented Jan 23, 2014

@jankatins
Copy link
Contributor Author

meat is a dataframe which is packaged with ggplot. Thanks for the fix!

@jreback
Copy link
Contributor

jreback commented Jan 24, 2014

grt...pls test if you can (I found that problem, but doens't hurt to do this)

@bnguyenvanyen
Copy link

Hi, the behaviour of df.get(None) seems inconsistent.
The previous compatibility fix caught ValueError: cannot label index with a null key.
On my dataframe however (too many columns ?), what gets raised is
TypeError: cannot label index with a null key, at line 3605 of core/internals.py

Could this get caught as well or does it break something ?

Thank you

@jorisvandenbossche
Copy link
Member

@bennguvaye if you think there is still a bug for a certain case, please open a new issue and add a small reproducible code example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants