So sieht der Datensatz aus
Code: Alles auswählen
import pandas as pd
d = {'col1': [1, 2, 3, 3], 'col2': [0, 1, 0, 1]}
df2 = pd.DataFrame(data=d)
Code: Alles auswählen
df2['col2'].isin([0]).sum()(df2['col1'] < 3)
Code: Alles auswählen
import pandas as pd
d = {'col1': [1, 2, 3, 3], 'col2': [0, 1, 0, 1]}
df2 = pd.DataFrame(data=d)
Code: Alles auswählen
df2['col2'].isin([0]).sum()(df2['col1'] < 3)
Code: Alles auswählen
In [170]: df2["col1"] < 3
Out[170]:
0 True
1 True
2 False
3 False
Name: col1, dtype: bool
In [171]: df2["col2"] == 0
Out[171]:
0 True
1 False
2 True
3 False
Name: col2, dtype: bool
In [172]: (df2["col1"] < 3) & (df2["col2"] == 0)
Out[172]:
0 True
1 False
2 False
3 False
dtype: bool
In [173]: ((df2["col1"] < 3) & (df2["col2"] == 0)).sum()
Out[173]: 1