I have one pandas DataFrame and I want to check the rows are identical. This shall work for 3 columns out of the dataframe.
A B C ... 1 1 1 ... 1 2 3 ... 1 4 4 ... This should bring up a mask with
True False False Or you can use nunique
df.nunique(1).eq(1) Out[1155]: 0 True 1 False 2 False dtype: bool Using diff
df.diff(axis=1).fillna(0).eq(0).all(1) 0 True 1 False 2 False dtype: bool Using shift
df.eq(df.shift(axis=1)).iloc[:, 1:].all(1) 0 True 1 False 2 False dtype: bool Using std (inspired by @Wen)
df.std(1).eq(0) 0 True 1 False 2 False dtype: bool Inspired by @MaxU with a healthy amount of obnoxious sprinkled in.
(lambda v, j: pd.Series((v == v[:, [0]]).all(1), j))(df.values, df.index) 0 True 1 False 2 False dtype: bool Now with less obnoxious
v = df.values pd.Series((v == v[:, [0]]).all(1), df.index)