A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/10126 below:

masking empty DataFrame · Issue #10126 · pandas-dev/pandas · GitHub

In pandas 0.16.1, I get a ValueError when trying to mask an empty DataFrame:

>>> import pandas as pd
>>> df = pd.DataFrame()
>>> df[df>0]
Traceback (most recent call last):

  File "<ipython-input-3-efe84c9ebabc>", line 1, in <module>
    df[df>0]

  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1787, in __getitem__
    return self._getitem_frame(key)

  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1859, in _getitem_frame
    raise ValueError('Must pass DataFrame with boolean values only')

ValueError: Must pass DataFrame with boolean values only

Using 'where' works as expected:

>>> df.where(df>0)
Out[4]: 
Empty DataFrame
Columns: []
Index: []

Also, masking a Series works as expected:

>>> ts = pd.Series()
>>> ts[ts>0]
Out[6]: Series([], dtype: float64)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4