0

I searched how to find same string values in multiple columns but I could only find a way to find duplicated rows.

My dataset looks like this:

NOTE_CONTENTDTL WARNSIGN_DTL
1   Hello world Hello world
2   Python is fun   Python is difficult
3   Python is funny as hell   Python is funny as hell

and I would like to print the rows which have same values in multiple columns

here is my expected result:

NOTE_CONTENTDTL WARNSIGN_DTL
    1   Hello world Hello world
    3   Python is funny as hell   Python is funny as hell
2 rows x 2 columns

I've tried this:

# df9 is dataframe, and 
# df_warnsign_dtl = df9.apply(lambda x: x.str.contains('Hello', na=False)).all(1)  such as to find rows which contain string 'Hello' out of df9

for index, row in df9[df_warnsign_dtl].iterrows():
    if row['NOTE_CONTENTDTL'] == row['WARNSIGN_DTL']:
        print(df9[df_warnsign_dtl])

but it's not a form of dataframe that I wanted

Joshua Chung
  • 113
  • 9

0 Answers0