在我当前正在处理的数据集中有一个名为Ground的列。该列中的值是世界各地不同板球场的名称。我想创建一个新列,其中的值必须是板球场所在的国家名称。下面是场地名称列表。
array(['Auckland', 'Southampton', 'Johannesburg', 'Brisbane', 'Bristol',
'Khulna', 'Wellington', 'Sydney', 'The Oval', 'Nairobi (Gym)',
'Durban', 'Cape Town', 'Brabourne', 'Perth', 'Gqeberha',
'Melbourne', 'Christchurch', 'Karachi', 'Manchester', 'Bridgetown',
'Belfast', 'King City (NW)', 'Hamilton', 'Colombo (RPS)',
'Port of Spain', 'Centurion', 'Dubai (DSC)', "Lord's",
'Nottingham', 'Basseterre', 'Nagpur', 'Mohali', 'Colombo (PSS)',
'Abu Dhabi', 'Hobart', 'Providence', 'Gros Islet', 'North Sound',
'Lauderhill', 'Harare', 'Birmingham', 'Cardiff', 'Bloemfontein',
'Kimberley', 'Adelaide', 'Pallekele', 'Mirpur', 'Eden Gardens',
'Mombasa', 'ICCA Dubai', 'Hambantota', 'The Hague',
'Chester-le-Street', 'Chennai', 'Pune', 'Wankhede', 'East London',
'Bengaluru', 'Ahmedabad', 'Sharjah', 'Windhoek', 'Bulawayo',
'Aberdeen', 'Kingstown', 'Rajkot', 'Chattogram', 'Kingston',
'Sylhet', 'Roseau', 'Lahore', 'Bready', 'Edinburgh',
'Dublin (Malahide)', 'Dharamsala', 'Cuttack', 'Mount Maunganui',
'Ranchi', 'Visakhapatnam', 'Delhi', 'Napier', 'Kanpur', 'Geelong',
'Greater Noida', 'Taunton', 'Guwahati', 'Potchefstroom',
'Thiruvananthapuram', 'Indore', 'Nelson', 'Dehradun', 'Rotterdam',
'Deventer', 'Amstelveen', 'Lucknow', 'Carrara', 'Al Amerat',
'ICCA 2 Dubai', 'Canberra', 'Hyderabad', "St George's",
'Rawalpindi', 'Paarl', 'Dunedin', 'Coolidge', 'Leeds', 'Dublin',
'Jaipur', 'Tarouba'], dtype=object)
我用另一个数据集逐个做了这些。然而,这个数据集是巨大的。
2条答案
按热度按时间5tmbdcev1#
作为起点,您可以使用Wikipedia:
输出:
您可以Map:
vu8f3i0k2#
我认为您可以使用
df.replace
,并对to_replace
参数使用一个dict,该参数定义板球场地名称和国家名称之间的Map。