我使用了很多列的汽车数据框。如果我得到某些制造商的外观计数:
carsDF.manufacturer.value_counts()
结果是这样的:
VW 2228
Opel 1414
Renault 1362
Audi 895
BMW 888
Mercedes-Benz 786
如果某制造商的外观总数少于一定数量,该如何从该制造商的数据框中删除所有行?
您可以制作地图:
# get the count for each manufacturer
counts = carsDF.manufacturer.value_counts()
# threshold
thresh = 1000
# replace the manufacturer with the counts and thresholding
carsDF[carsDF.manufacturer.map(counts).ge(thresh)]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句