df = pd.DataFrame(data)# 删除重复行,保留第一次出现的行df_no_duplicates = df.drop_duplicates() print(df_no_duplicates) 2)基于特定列删除重复行 importpandasaspd# 创建示例DataFramedata = {'A': [1,2,2,3,4,4,5],'B': ['a','b','b','c','d','d','e']} df = pd.DataFrame(d...
To drop consecutive columns, we will use the:operator. We can use column names or column positions. Both give the same output. We will remove columns2to7from our data frame; columns fromCol2toBdplyr. We will be left with the first and last columns,Col1andBBdplyr. ...