-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: cannot reindex from a duplicate axis #49
Comments
See #41. I think we should make the error message more useful, but this is likely a problem with your source or target geometries containing overlaps. If these are indeed Census blocks/vtds, then you likely have duplicates. Let me know if this helps! |
these ARE census blocks being mapped to VTD's. However the VTD's (for Texas, from the MGGG state archive for 2010) got 'buffered' to avoid a point defect that prevented a Graph getting made. possibly using the straight MGGG vtd archive for TX could be a workaround - we'll see. Idea being to then map the 2010 census blocks to the 2020 census vtd's so I can have a database with the 2010 AND 2020 population stats all in 1 place so I can do interesting population change comparisons |
VEST already did this, I believe. |
you have a link for that repo? What I see at the general link https://dataverse.harvard.edu/file.xhtml?fileId=5007853&version=17.0 is stuff on 2020 election results but not obviously combining 2010 and 2020 demographics. Missing PA incidentally. I just got the comprehensive precinct results from PA sec'y of state - anyone I should send those to so they can integrate it with other datasets? |
there also is their repo with "crosswalks" |
Sorry for the delay -- I thought that VEST had this data prepared, but maybe not. |
#48 should silence the issue for you, I believe. Could you share the shapefiles that you're using? Also, did you make sure that your source and target shapefiles have the same projection? |
I had this same issue. I checked the axes of my dataframes and no duplicates exist. ValueError Traceback (most recent call last) ~\anaconda3\lib\site-packages\maup\crs.py in wrapped(*args, **kwargs) ~\anaconda3\lib\site-packages\maup\assign.py in assign(sources, targets) ~\anaconda3\lib\site-packages\maup\assign.py in assign_by_covering(sources, targets) ~\anaconda3\lib\site-packages\maup\indexed_geometries.py in assign(self, targets) ~\anaconda3\lib\site-packages\pandas\core\series.py in reindex(self, index, **kwargs) ~\anaconda3\lib\site-packages\pandas\core\generic.py in reindex(self, *args, **kwargs) ~\anaconda3\lib\site-packages\pandas\core\generic.py in _reindex_axes(self, axes, level, limit, tolerance, method, fill_value, copy) ~\anaconda3\lib\site-packages\pandas\core\generic.py in _reindex_with_indexers(self, reindexers, fill_value, copy, allow_dups) ~\anaconda3\lib\site-packages\pandas\core\internals\managers.py in reindex_indexer(self, new_axis, indexer, axis, fill_value, allow_dups, copy, consolidate, only_slice) ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in _validate_can_reindex(self, indexer) ValueError: cannot reindex from a duplicate axis |
the shapefiles I used were at: |
then maup.assign just crashes... after spending a while getting thru the assignments. example:
In [10]: assign1 = maup.assign(blocks20, vtds10)
100%|██████████| 8941/8941 [11:36<00:00, 12.85it/s]
Traceback (most recent call last):
File "", line 1, in
assign1 = maup.assign(blocks20, vtds10)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/maup/crs.py", line 14, in wrapped
return f(*args, **kwargs)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/maup/assign.py", line 12, in assign
assignment = assign_by_covering(sources, targets)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/maup/assign.py", line 22, in assign_by_covering
return indexed_sources.assign(targets)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/maup/indexed_geometries.py", line 42, in assign
assignment = pandas.concat(groups).reindex(self.index)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/pandas/core/series.py", line 4579, in reindex
return super().reindex(index=index, **kwargs)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 4810, in reindex
axes, level, limit, tolerance, method, fill_value, copy
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 4834, in _reindex_axes
allow_dups=False,
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 4880, in _reindex_with_indexers
copy=copy,
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 663, in reindex_indexer
self.axes[axis]._validate_can_reindex(indexer)
File "/Users/dpg/opt/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3785, in _validate_can_reindex
raise ValueError("cannot reindex from a duplicate axis")
ValueError: cannot reindex from a duplicate axis
The text was updated successfully, but these errors were encountered: