Reputation: 11
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
Above is the data set of the companies name where some name have appears ones in same case two are more than two. i want a code to arrange them up. Some company names have appears more then one but are at different location, How to arrange them to one location? actually i want to count which company appears the most in the data. if there is any other way to find out which name appears the most please advise
Upvotes: 0
Views: 56
Reputation: 471
You can use Pandas.
try this,
import pandas as pd
I created a file for the data you provided and then imported it:
df = pd.read_csv('company.txt', header=0)
file looks like this,
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"
....
then,
Get the most repeated name like this,
print('**Name most repeated**')
print(df['name'].value_counts().idxmax())
get the number of times that name was repeated.
print('**this many times**')
print(df['name'].value_counts().max())
For the data you provided the output looks like this,
**Name most repeated**
Rightway Logistics
**this many times**
5
Upvotes: 1