Town FormatterΒΆ

import pandas as pd
towns = pd.read_csv('towns.csv', header=None, names=['Town', 'Type', 'County',  'Governance', 'Population 2010','Year Established'])
towns.head()
Town Type County Governance Population 2010 Year Established
0 Abington Town Plymouth Open town meeting 15,985 1712
1 Acton Town Middlesex Open town meeting 21,924 1735
2 Acushnet Town Bristol Open town meeting 10,303 1860
3 Adams Town Berkshire Representative town meeting 8,485 1778
4 Agawam City[4] Hampden Mayor-council 28,438 1855
print(', '.join([n.replace(' ', '_').replace('-','_') for n in towns['Town'].values]))
Abington, Acton, Acushnet, Adams, Agawam, Alford, Amesbury, Amherst, Andover, Aquinnah, Arlington, Ashburnham, Ashby, Ashfield, Ashland, Athol, Attleboro, Auburn, Avon, Ayer, Barnstable, Barre, Becket, Bedford, Belchertown, Bellingham, Belmont, Berkley, Berlin, Bernardston, Beverly, Billerica, Blackstone, Blandford, Bolton, Boston, Bourne, Boxborough, Boxford, Boylston, Braintree, Brewster, Bridgewater, Brimfield, Brockton, Brookfield, Brookline, Buckland, Burlington, Cambridge, Canton, Carlisle, Carver, Charlemont, Charlton, Chatham, Chelmsford, Chelsea, Cheshire, Chester, Chesterfield, Chicopee, Chilmark, Clarksburg, Clinton, Cohasset, Colrain, Concord, Conway, Cummington, Dalton, Danvers, Dartmouth, Dedham, Deerfield, Dennis, Dighton, Douglas, Dover, Dracut, Dudley, Dunstable, Duxbury, East_Bridgewater, East_Brookfield, East_Longmeadow, Eastham, Easthampton, Easton, Edgartown, Egremont, Erving, Essex, Everett, Fairhaven, Fall_River, Falmouth, Fitchburg, Florida, Foxborough, Framingham, Franklin, Freetown, Gardner, Georgetown, Gill, Gloucester, Goshen, Gosnold, Grafton, Granby, Granville, Great_Barrington, Greenfield, Groton, Groveland, Hadley, Halifax, Hamilton, Hampden, Hancock, Hanover, Hanson, Hardwick, Harvard, Harwich, Hatfield, Haverhill, Hawley, Heath, Hingham, Hinsdale, Holbrook, Holden, Holland, Holliston, Holyoke, Hopedale, Hopkinton, Hubbardston, Hudson, Hull, Huntington, Ipswich, Kingston, Lakeville, Lancaster, Lanesborough, Lawrence, Lee, Leicester, Lenox, Leominster, Leverett, Lexington, Leyden, Lincoln, Littleton, Longmeadow, Lowell, Ludlow, Lunenburg, Lynn, Lynnfield, Malden, Manchester_by_the_Sea, Mansfield, Marblehead, Marion, Marlborough, Marshfield, Mashpee, Mattapoisett, Maynard, Medfield, Medford, Medway, Melrose, Mendon, Merrimac, Methuen, Middleborough, Middlefield, Middleton, Milford, Millbury, Millis, Millville, Milton, Monroe, Monson, Montague, Monterey, Montgomery, Mount_Washington, Nahant, Nantucket, Natick, Needham, New_Ashford, New_Bedford, New_Braintree, New_Marlborough, New_Salem, Newbury, Newburyport, Newton, Norfolk, North_Adams, North_Andover, North_Attleborough, North_Brookfield, North_Reading, Northampton, Northborough, Northbridge, Northfield, Norton, Norwell, Norwood, Oak_Bluffs, Oakham, Orange, Orleans, Otis, Oxford, Palmer, Paxton, Peabody, Pelham, Pembroke, Pepperell, Peru, Petersham, Phillipston, Pittsfield, Plainfield, Plainville, Plymouth, Plympton, Princeton, Provincetown, Quincy, Randolph, Raynham, Reading, Rehoboth, Revere, Richmond, Rochester, Rockland, Rockport, Rowe, Rowley, Royalston, Russell, Rutland, Salem, Salisbury, Sandisfield, Sandwich, Saugus, Savoy, Scituate, Seekonk, Sharon, Sheffield, Shelburne, Sherborn, Shirley, Shrewsbury, Shutesbury, Somerset, Somerville, South_Hadley, Southampton, Southborough, Southbridge, Southwick, Spencer, Springfield, Sterling, Stockbridge, Stoneham, Stoughton, Stow, Sturbridge, Sudbury, Sunderland, Sutton, Swampscott, Swansea, Taunton, Templeton, Tewksbury, Tisbury, Tolland, Topsfield, Townsend, Truro, Tyngsborough, Tyringham, Upton, Uxbridge, Wakefield, Wales, Walpole, Waltham, Ware, Wareham, Warren, Warwick, Washington, Watertown, Wayland, Webster, Wellesley, Wellfleet, Wendell, Wenham, West_Boylston, West_Bridgewater, West_Brookfield, West_Newbury, West_Springfield, West_Stockbridge, West_Tisbury, Westborough, Westfield, Westford, Westhampton, Westminster, Weston, Westport, Westwood, Weymouth, Whately, Whitman, Wilbraham, Williamsburg, Williamstown, Wilmington, Winchendon, Winchester, Windsor, Winthrop, Woburn, Worcester, Worthington, Wrentham, Yarmouth
', '.join([n.replace(',', '') for n in towns['Population 2010'].values])
'15985, 21924, 10303, 8485, 28438, 494, 16283, 37819, 33201, 311, 42844, 6081, 3074, 1737, 16593, 11584, 43593, 16188, 4356, 7427, 45193, 5398, 1779, 13320, 14649, 16332, 24729, 6411, 2866, 2129, 39502, 40243, 9026, 1233, 4897, 617660, 19754, 4996, 7965, 4355, 35744, 9820, 26563, 3609, 93810, 3390, 58732, 1902, 24498, 105162, 21561, 4852, 11509, 1266, 12981, 6125, 33802, 35177, 3235, 1337, 1222, 55298, 866, 1702, 13606, 7542, 1671, 17668, 1897, 872, 6756, 26493, 34032, 24729, 5125, 14207, 7086, 8471, 5589, 29457, 11390, 3179, 15059, 13794, 2183, 15720, 4956, 16053, 23112, 4067, 1225, 1800, 3504, 41667, 15873, 88857, 31531, 40318, 752, 16865, 68318, 31635, 8870, 20228, 8183, 1500, 28789, 1054, 75, 17765, 6240, 1566, 7104, 17456, 10646, 6459, 5250, 7518, 7764, 5139, 717, 13879, 10209, 2990, 6520, 12243, 3279, 60879, 337, 706, 22157, 2032, 10791, 17346, 2481, 13547, 39880, 5911, 14925, 4382, 19063, 10293, 2180, 13175, 12629, 10602, 8055, 3091, 76377, 5943, 10970, 5025, 40759, 1851, 31394, 711, 6362, 8924, 15784, 106519, 21103, 10086, 90329, 11596, 59450, 5136, 23184, 19808, 4907, 38499, 25132, 14006, 6045, 10106, 12024, 56173, 12752, 26983, 5839, 6338, 47255, 23116, 521, 8987, 27999, 13261, 7891, 3190, 27003, 121, 8560, 8437, 961, 838, 167, 3410, 10172, 33006, 28886, 228, 95072, 999, 1509, 990, 6666, 17416, 85146, 11227, 13708, 28352, 28712, 4680, 14892, 28549, 14155, 15707, 3032, 19031, 10506, 28602, 4527, 1902, 7839, 5890, 1612, 13709, 12140, 4806, 51251, 1321, 17837, 11497, 847, 1234, 1682, 44737, 648, 8264, 56468, 2820, 3413, 2942, 92271, 32112, 13383, 24747, 11608, 51755, 1475, 5232, 17489, 6952, 393, 5856, 1258, 1775, 7973, 41340, 8283, 915, 20675, 26628, 692, 18133, 13722, 17612, 3257, 1893, 4119, 7211, 35608, 1771, 18165, 75754, 17514, 5792, 9767, 16719, 9502, 11688, 153060, 7808, 1947, 21437, 26962, 6590, 9268, 17659, 3684, 8963, 13787, 15865, 55874, 8013, 28961, 3949, 485, 6085, 8926, 2003, 11292, 327, 7542, 13457, 24932, 1838, 24070, 60632, 9872, 21822, 5135, 780, 538, 31915, 12994, 16767, 27982, 2750, 848, 4875, 7669, 6916, 3701, 4235, 28391, 1306, 2740, 18272, 41094, 21951, 1607, 7277, 11261, 15532, 14618, 53743, 1496, 14489, 14219, 2482, 7754, 22325, 10300, 21374, 899, 17497, 38120, 181045, 1156, 10955, 23793'