Run
import pandas as pd # Take a sample DataFrame df = pd.DataFrame({ 'A': [1, 2, 1, 1, 3], 'B': [5, 4, 5, 5, 5], 'C': [9, 10, 9, 9, 8]}) # Remove duplicate rows based on column 'B' df_no_duplicates = df.drop_duplicates(subset=['B']) print(f"Original DataFrame\n{df}\n") print(f"DataFrame with no duplicates\n{df_no_duplicates}")
Output