Skip to content

Add support for pandas.BooleanDtype #468

Answered by cosmicBboy
mattHawthorn asked this question in Q&A
Discussion options

You must be logged in to vote

hey @mattHawthorn! the pandera pandas_dtype also does accept any of the pandas extension types, including pd.BooleanDtype() or the uninstantiated pd.BooleanDtype (in the case of extension dtypes that don't take any arguments).

So this should work:

In [1]: import pandas as pd

In [2]: import pandera as pa
s =
In [3]: s = pd.Series([True, False, None], dtype=pd.BooleanDtype())

In [4]: schema = pa.SeriesSchema(pd.BooleanDtype(), nullable=True)

In [5]: schema(s)
Out[5]:
0     True
1    False
2     <NA>
dtype: boolean

In [6]: schema = pa.SeriesSchema(pd.BooleanDtype, nullable=True)

In [7]: schema(s)
Out[7]:
0     True
1    False
2     <NA>
dtype: boolean

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mfarragher
Comment options

@cosmicBboy
Comment options

Answer selected by cosmicBboy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #442 on April 21, 2021 13:21.