Home > Enterprise >  How does a bool type in a dataframe and?
How does a bool type in a dataframe and?

Time:01-05

A bool type dataframe:

m = df_device_commission[['X']].gt(0).any(axis=1)

print(m)

0      True
1      True
2      True
3     False
4      True
dtype: bool

another bool type dataframe:

n = df_device_commission[['Y']].notna().any(axis=1)

print(n)

0     False
1     False
2     False
3     False
4      True
dtype: bool

If I want to m and n, How should I write the code?

CodePudding user response:

You can use numpy.logical_and:

In [377]: import numpy as np

In [378]: np.logical_and(m,n)
Out[378]: 
0    False
1    False
2    False
3    False
4     True
dtype: bool

CodePudding user response:

You can use the & operator.

>>> m & n

0    False
1    False
2    False
3    False
4     True
dtype: bool
  •  Tags:  
  • Related