最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - To Merge Slightly Different Matching Fields - Stack Overflow

programmeradmin5浏览0评论

I'm currently working with an air quality dataset that gives air quality values for each New York City community district area. I am trying to factor in population density into each, and thought I'd just be able to map the density values I've calculated to each air quality instance in a new column. However, I've realized that all the district names have ever so slightly different labels.

For example, in the air quality dataset, it's "Melrose, Mott Haven, Port Morris", with a separate column giving the code, "Bronx CD 1", while in the population density dataset it's "Mott Haven and Melrose (CD1)".

It's the same number, but how would I go about mapping the two values together with the slight dissimilarities?

Also, unfortunately the air quality dataset doesn't include Boro, so I can't just use the cd number and the boro combo (CD numbers are repeated per boro).

community name 1: ['Melrose, Mott Haven, Port Morris (CD1)' 'Hunts Point, Longwood (CD2)' 'Morrisania, Crotona Park East (CD3)' 'Highbridge, Concourse Village (CD4)' 'University Hts., Fordham, Mt. Hope (CD5)' 'East Tremont, Belmont (CD6)' 'Bedford Park, Norwood, Fordham (CD7)' 'Riverdale, Kingsbridge, Marble Hill (CD8)' 'Soundview, Parkchester (CD9)' 'Throgs Nk., Co-op City, Pelham Bay (CD10)' 'Pelham Pkwy, Morris Park, Laconia (CD11)' 'Wakefield, Williamsbridge (CD12)' 'Williamsburg, Greenpoint (CD1)' 'Brooklyn Heights, Fort Greene (CD2)' 'Bedford Stuyvesant (CD3)' 'Bushwick (CD4)' 'East New York, Starrett City (CD5)' 'Park Slope, Carroll Gardens (CD6)' 'Sunset Park, Windsor Terrace (CD7)' 'Crown Heights North (CD8)' 'Crown Heights South, Wingate (CD9)' 'Bay Ridge, Dyker Heights (CD10)' 'Bensonhurst, Bath Beach (CD11)' 'Borough Park, Ocean Parkway (CD12)' 'Coney Island, Brighton Beach (CD13)' 'Flatbush, Midwood (CD14)' 'Sheepshead Bay, Gerritsen Beach (CD15)' 'Brownsville, Ocean Hill (CD16)' 'East Flatbush, Rugby, Farragut (CD17)' 'Canarsie, Flatlands (CD18)' 'Battery Park City, Tribeca (CD1)' 'Greenwich Village, Soho (CD2)' 'Lower East Side, Chinatown (CD3)' 'Chelsea, Clinton (CD4)' 'Midtown Business District (CD5)' 'Stuyvesant Town, Turtle Bay (CD6)' 'West Side, Upper West Side (CD7)' 'Upper East Side (CD8)' 'Manhattanville, Hamilton Heights (CD9)' 'Central Harlem (CD10)' 'East Harlem (CD11)' 'Washington Heights, Inwood (CD12)' 'Astoria, Long Island City (CD1)' 'Sunnyside, Woodside (CD2)' 'Jackson Heights, North Corona (CD3)' 'Elmhurst, South Corona (CD4)' 'Ridgewood, Glendale, Maspeth (CD5)' 'Forest Hills, Rego Park (CD6)' 'Flushing, Bay Terrace (CD7)' 'Fresh Meadows, Briarwood (CD8)' 'Woodhaven, Richmond Hill (CD9)' 'Ozone Park, Howard Beach (CD10)' 'Bayside, Douglaston, Little Neck (CD11)' 'Jamaica, St. Albans, Hollis (CD12)' 'Queens Village, Rosedale (CD13)' 'The Rockaways, Broad Channel (CD14)' 'Stapleton, Port Richmond (CD1)' 'New Springville, South Beach (CD2)' 'Tottenville, Woodrow, Great Kills (CD3)']

community names 2 = ['Melrose, Mott Haven, Port Morris (CD1)' 'Hunts Point, Longwood (CD2)' 'Morrisania, Crotona Park East (CD3)' 'Highbridge, Concourse Village (CD4)' 'University Hts., Fordham, Mt. Hope (CD5)' 'East Tremont, Belmont (CD6)' 'Bedford Park, Norwood, Fordham (CD7)' 'Riverdale, Kingsbridge, Marble Hill (CD8)' 'Soundview, Parkchester (CD9)' 'Throgs Nk., Co-op City, Pelham Bay (CD10)' 'Pelham Pkwy, Morris Park, Laconia (CD11)' 'Wakefield, Williamsbridge (CD12)' 'Williamsburg, Greenpoint (CD1)' 'Brooklyn Heights, Fort Greene (CD2)' 'Bedford Stuyvesant (CD3)' 'Bushwick (CD4)' 'East New York, Starrett City (CD5)' 'Park Slope, Carroll Gardens (CD6)' 'Sunset Park, Windsor Terrace (CD7)' 'Crown Heights North (CD8)' 'Crown Heights South, Wingate (CD9)' 'Bay Ridge, Dyker Heights (CD10)' 'Bensonhurst, Bath Beach (CD11)' 'Borough Park, Ocean Parkway (CD12)' 'Coney Island, Brighton Beach (CD13)' 'Flatbush, Midwood (CD14)' 'Sheepshead Bay, Gerritsen Beach (CD15)' 'Brownsville, Ocean Hill (CD16)' 'East Flatbush, Rugby, Farragut (CD17)' 'Canarsie, Flatlands (CD18)' 'Battery Park City, Tribeca (CD1)' 'Greenwich Village, Soho (CD2)' 'Lower East Side, Chinatown (CD3)' 'Chelsea, Clinton (CD4)' 'Midtown Business District (CD5)' 'Stuyvesant Town, Turtle Bay (CD6)' 'West Side, Upper West Side (CD7)' 'Upper East Side (CD8)' 'Manhattanville, Hamilton Heights (CD9)' 'Central Harlem (CD10)' 'East Harlem (CD11)' 'Washington Heights, Inwood (CD12)' 'Astoria, Long Island City (CD1)' 'Sunnyside, Woodside (CD2)' 'Jackson Heights, North Corona (CD3)' 'Elmhurst, South Corona (CD4)' 'Ridgewood, Glendale, Maspeth (CD5)' 'Forest Hills, Rego Park (CD6)' 'Flushing, Bay Terrace (CD7)' 'Fresh Meadows, Briarwood (CD8)' 'Woodhaven, Richmond Hill (CD9)' 'Ozone Park, Howard Beach (CD10)' 'Bayside, Douglaston, Little Neck (CD11)' 'Jamaica, St. Albans, Hollis (CD12)' 'Queens Village, Rosedale (CD13)' 'The Rockaways, Broad Channel (CD14)' 'Stapleton, Port Richmond (CD1)' 'New Springville, South Beach (CD2)' 'Tottenville, Woodrow, Great Kills (CD3)']

发布评论

评论列表(0)

  1. 暂无评论