The Pandas api types function is_bool() used to determine whether the specified object is boolean. It returns a boolean value that specifies whether the specified object is boolean.
1 Pandas.api.types.is_bool()
obj : It is an object to determine whether specified object is a boolean.
1 from pandas.api.types import is_bool
2
3 res1 = is_bool(True)
4 print(f'Is it bool object : {res1}')
5
6 res2 = is_bool(1)
7 print(f'Is it bool object : {res2}')
In the above example, an is_bool() function is called by passing a different values. It returns a boolean value that specifies whether the specified value is boolean. The result is assign to the variable that will be printed on console.
1 Is it bool object : False
2 Is it bool object : True
Example 2
1 from pandas.api.types import is_bool
2
3 res1 = is_bool('b')
4 print(f'Is it bool object : {res1}')
5
6 res2 = is_bool(10 > 5)
7 print(f'Is it bool object : {res2}')
In the above example, an is_bool() function is called by passing a different values. It returns a boolean value that specifies whether the specified value is boolean. The result is assign to the variable that will be print.
1 Is it bool object : False
2 Is it bool object : True
Example 3
1 from pandas.api.types import is_bool
2
3 res1 = is_bool('Hello')
4 print(f'Is it bool object : {res1}')
5
6 res2 = is_bool(1 == 1)
7 print(f'Is it bool object : {res2}')
In the above example, an is_bool() function is called by passing a different values. It returns a boolean value that specifies whether the specified value is boolean. The result is assign to the variable that will be print.
1 Is it bool object : False
2 Is it bool object : True
Related options for your search