Scott Logistics Corp
Transportation One LLC
Brothers Logistics Inc
Western Express Inc
Dart Advantage Logistics
Western Express Inc
Western Express Inc
Landstar Inway
Circle Logistics Inc
Rightway Logistics
Rightway Logistics
Rightway Logistics
Spike Freight Service
Rightway Logistics
Rightway Logistics
AMX Logistics
T A Services Inc Formerly Team America Inc
J & R Schugel/Super Service
NFI Logistics/NFI Transportation
Titanium Trucking Services/Titanium Logistics
Patterson Companies Inc
Arrive Logistics
Cavalry Logistics Llc
Landstar Ranger Inc
Landstar Ranger Inc
Logistic Dynamics Inc/Ldi Trucking Inc
US Xpress Inc
US Xpress Inc
XPO Logistics LLC
Bedrock Logistics
Transfix Inc
Convoy Inc
Choctaw Logistics Llc
Trekker Logistics LLC
Landstar Ranger Inc
MAG Carriers Llc/Mag Transportation Llc
Capital Logistics Group LLC/Clg Transportation
Capital Logistics Group LLC/Clg Transportation
Landstar Ranger Inc
XPO Logistics LLC上面是公司名称的数据集,在相同的情况下,某个名字出现了一个,两个多于两个。我想要一个密码来安排他们。有些公司的名称出现得比一个公司多,但在不同的位置,如何将它们排列到一个位置?实际上我想数一数哪家公司在数据中出现得最多。如果有其他方法来找出哪个名字出现得最多,请告诉我。
发布于 2019-12-30 21:10:50
您可以从集合(python中的核心模块之一)使用Counter函数,您不需要安装它:
from collections import Counter
counts = Counter(your_list)发布于 2019-12-30 21:29:03
你可以用潘达斯。
尝尝这个,
import pandas as pd我为您提供的数据创建了一个文件,然后导入它:
df = pd.read_csv('company.txt', header=0)文件看起来像这样,
name
"Scott Logistics Corp"
"Transportation One LLC"
"Brothers Logistics Inc"
"Western Express Inc"
"Dart Advantage Logistics"
"Western Express Inc"
"Western Express Inc"
"Landstar Inway"
"Circle Logistics Inc"
....然后,
像这样重复最多的名字,
print('**Name most repeated**')
print(df['name'].value_counts().idxmax())获取重复该名称的次数。
print('**this many times**')
print(df['name'].value_counts().max())对于您提供的数据,输出如下所示
**Name most repeated**
Rightway Logistics
**this many times**
5https://stackoverflow.com/questions/59536841
复制相似问题