Pandas: number of rows where df[‘A’] == df[‘B’] or df[‘B’] == []

Consider following dataframe df with columns A and B. I am trying to find the number of rows where df['A'] == df['B'] or df['B'] == []. How can I do this?

                  A                          B
m:QueryId       
970000000   [0, 1, 2, 3, 4, 5]      [0, 1, 2, 3, 4, 5]
970000001   [0]                                    [0]
970000002   [1, 2, 3, 4, 5]                         []
970000003   [0, 1, 2, 3]                            []
970000004   [1, 2, 4]                            [5,6]

Answer

Try with :

df[df['A'].eq(df['B'])|~df['B'].astype(bool)]

For count of such rows:

(df['A'].eq(df['B'])|~df['B'].astype(bool)).sum()