C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Pandas DataFrame.drop_duplicates()The drop_duplicates() function performs common data cleaning task that deals with duplicate values in the DataFrame. This method helps in removing duplicate values from the DataFrame. SyntaxDataFrame.drop_duplicates(subset=None, keep='first', inplace=False) Parameters
If it is true, it removes the rows with duplicate values. ReturnDepending on the arguments passed, it returns the DataFrame with the removal of duplicate rows. Exampleimport pandas as pd emp = {"Name": ["Parker", "Smith", "William", "Parker"], "Age": [21, 32, 29, 21]} info = pd.DataFrame(emp) print(info) Output Name Age 0 Parker 21 1 Smith 32 2 William 29 3 Parker 21 import pandas as pd emp = {"Name": ["Parker", "Smith", "William", "Parker"], "Age": [21, 32, 29, 21]} info = pd.DataFrame(emp) info = info.drop_duplicates() print(info) Output Name Age 0 Parker 21 1 Smith 32 2 William 29
Next TopicDataFrame.groupby()
|