<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
I am trying to find duplicates col rows in a pandas dataframe.
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
df=pd.DataFrame(data=[[1,1,2,5],[1,3,4,1],[4,1,2,5],[5,1,4,9],[1,1,2,5]],columns=['val', 'col1','col2','3col'])
def g(df):
    cols = list(df.filter(like='col'))
    df['index_original'] = df.groupby(cols)[cols[0]].transform('idxmax')
    for i in range(len(df)):
        i = len(df) - 1 - i
        origin = df.loc[i, 'index_original']
        if i <= origin:
            continue
        if origin == df.loc[origin, 'index_original']:
            df.loc[origin, 'index_original'] = i
        df.loc[i, 'index_original'] = df.loc[origin, 'index_original']
    return df[df.duplicated(subset=cols, keep='last')]
result = g(df.copy())
<END_TASK>