Skip to content
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

Pandas ValueError when calling subtract_drift #734

Open
kevin-duclos opened this issue May 24, 2023 · 1 comment
Open

Pandas ValueError when calling subtract_drift #734

kevin-duclos opened this issue May 24, 2023 · 1 comment

Comments

@kevin-duclos
Copy link
Contributor

kevin-duclos commented May 24, 2023

Running motion.subtract_drift sometimes produces the error below, depending on the data. Possibly related to issue #730.

/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/trackpy/motion.py:315: FutureWarning: reindexing with a non-unique Index is deprecated and will raise in a future version.
  traj[col] = traj[col].sub(drift[col], fill_value=0, level='frame')
Traceback (most recent call last):
  File "/Users/kevinadmin/Work/Code/pythons/diatom-sinking-processing/main.py", line 231, in <module>
    main(filepath_seq)
  File "/Users/kevinadmin/Work/Code/pythons/diatom-sinking-processing/main.py", line 147, in main
    traj_minus_drift = tp.subtract_drift(traj=traj, drift=drift_sub)
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/trackpy/motion.py", line 315, in subtract_drift
    traj[col] = traj[col].sub(drift[col], fill_value=0, level='frame')
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/frame.py", line 3980, in __setitem__
    self._set_item(key, value)
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/frame.py", line 4174, in _set_item
    value = self._sanitize_column(value)
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/frame.py", line 4912, in _sanitize_column
    return _reindex_for_setitem(Series(value), self.index)
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/frame.py", line 12025, in _reindex_for_setitem
    raise err
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/frame.py", line 12020, in _reindex_for_setitem
    reindexed_value = value.reindex(index)._values
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/series.py", line 5094, in reindex
    return super().reindex(**kwargs)
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/generic.py", line 5289, in reindex
    return self._reindex_axes(
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/generic.py", line 5309, in _reindex_axes
    obj = obj._reindex_with_indexers(
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/generic.py", line 5355, in _reindex_with_indexers
    new_data = new_data.reindex_indexer(
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 737, in reindex_indexer
    self.axes[axis]._validate_can_reindex(indexer)
  File "/Users/kevinadmin/miniconda3/envs/trackpy/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 4316, in _validate_can_reindex
    raise ValueError("cannot reindex on an axis with duplicate labels")
ValueError: cannot reindex on an axis with duplicate labels
@kevin-duclos
Copy link
Contributor Author

Associated pull request: #735

caspervdw pushed a commit that referenced this issue Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant