Skip to content
The Chat Archive
claude-2.1· Anthropic Arena Human Preference 55K

I have received a pandas dtype of 'boolean' (not 'bool') - how is this possible?

  1. User

    I have received a pandas dtype of 'boolean' (not 'bool') - how is this possible?

  2. Assistant

    It is not actually possible to have a pandas dtype of exactly 'boolean'. Pandas uses 'bool' for Boolean data. Some things to note:

    • Pandas officially supports a 'bool' dtype to represent Boolean/logical data. This is aliased from the NumPy 'bool_' dtype.

    • In older versions of pandas (pre 0.25), the string representation of the 'bool' dtype was 'boolean'. So you may see this in printouts or reprs. However, the actual dtype string remains 'bool'.

    • If you view the dtypes on a DataFrame, you will see 'bool', not 'boolean'. And the numpy dtype will be bool_.

    • There were plans at one point to rename the pandas Boolean dtype to 'boolean' for consistency with other data types like 'integer' and 'floating'. But ultimately the 'bool' name was kept.

    So in summary, pandas does not ever use an exact dtype string 'boolean', only 'bool'. The 'boolean' name can appear in some places for legacy reasons, but the actual dtype will be 'bool'. Seeing 'boolean' likely just refers to the 'bool' dtype.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.