运行 ❯
获取你
自己的 Python
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
import pandas as pd data = { "name": ["John", "Mary", "John", "Sally", "Mary"], "age": [40, 30, 40, 50, 30], "city": ["Bergen", "Oslo", "Stavanger", "Oslo", "Oslo"] } df = pd.DataFrame(data) s = df.duplicated(keep=False) print(s) #With the keep parameter set to False, also the first occurence of a duplicate is set to True. #Column 1 returns True because it is identical to column 4. #Column 4 returns True because it is identical to column 1.
0 False 1 True 2 False 3 False 4 True dtype: bool