You can handle duplicate data using the drop_duplicates() method to remove duplicate rows or by using the duplicated() method to identify duplicates.
Example Code:
import pandas as pd
data = {'A': [1, 2, 2, 3, 4],
'B': ['X', 'Y', 'Y', 'Z', 'X']}
df = pd.DataFrame(data)
# Remove duplicate rows
df.drop_duplicates(inplace=True)
# Identify duplicate rows based on a subset of columns (column 'B' in this case)
duplicates = df[df.duplicated(subset=['B'])]