【发布时间】:2017-09-12 17:54:25
【问题描述】:
数据框:
> df
>type(df)
pandas.core.frame.DataFrame
ID Property Type Amenities
1952043 Apartment, Villa, Apartment Park, Jogging Track, Park
1918916 Bungalow, Cottage House, Cottage, Bungalow Garden, Play Ground
我怎样才能在数据框行中只保留用“逗号”分隔的唯一单词?在这种情况下,它不得将“Cottage House”和“Cottage”视为相同。它必须检查数据框的所有列。所以我想要的输出应该如下所示: 期望的输出:
ID Property Type Amenities
1952043 Apartment, Villa Park, Jogging Track
1918916 Bungalow, Cottage House, Cottage Garden, Play Ground
【问题讨论】:
标签: python-3.x pandas set pattern-matching unique