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/7897 below:

bool(MultiIndex) seems to always return False · Issue #7897 · pandas-dev/pandas · GitHub

This means that patterns such as:

if my_frame.index:
    # do something

with my_frame having a MultiIndex will never enter the if block. One can check that bool(my_frame.index) returns False. A single index (pandas.Index) will (correctly IMO) raise a ValueError warning that the truth value of an array is ambiguous. However, a MultiIndex fails silently.

This is such an awesome source of silent bugs that I'm surprised this hasn't come up before. Is there any reason why we want bool to return False every time for a MultiIndex?


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