I'm editing a shapefile for an election map, so I downloaded some county level vote totals and am adding them to a preexisting shapefile. This works for the most part (I can produce most of a new map with the added data) and I have been able to solve most problems I get, but I am stuck on something.
After joining the edited CSV file, most of the new attribute table fills out correctly and can be mapped, but some precinct vote counts are left null. After investigating, I discovered these null precincts are all precinct names that are reused in other counties (counties which have not yet been completed). I have only completed 5 counties so far. In the attribute table of the CSV file, the same precinct fields are not null, and correctly filled out.
The data appears to be organized using two fields, with one field labeled "COUNTYFP", indicating the county using an FIPS code, and the other labeled "NAME", indicating the name of the precinct within the county. Some precinct names are used in multiple counties, and I'm guessing that is the problem, though the original shapefile I started with didn't have any problems with that until I joined more data.
Here is a sample of the attribute table of the CSV file. This is just one small county (Alexander county, IL), but it illustrates the point. Notice how the precinct named "CACHE" has data across all fields.
After joining, this is the resultant portion of attribute table for the same county. The same precinct ("CACHE") now has null values across all fields.
This is the map I get, notice that there is a missing portion. my code is definitely working, bit I think the problem is with the join I am performing. There is another "CACHE" precinct in another county. It has exactly the same name, but a different "COUNTYFPS" number.
Here is snapshot of the the two precincts in an attribute table for the shapefile of a different election (a shapefile which I downloaded). It differentiates the two, despite them having the same name. The resulting map colors both precincts differently in accordance with my color coding.