Hello given a dataframe I would like to check that all the values of a particular column are equal to 9.
import pandas as pd
import numpy as np
df = pd.DataFrame(data=[[1,2],[2,9],[np.nan,9],[3,9]],columns=['A','B'])
df
A B
0 1.0 2
1 2.0 9
2 NaN 9
3 3.0 9
My solution would be:
if ((df.loc[:,"B"].unique()==[9]).all()):
...
Is there a better way to do so?