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

Calculation angle error,My version is 0.07 #49

Open
wyclearnpy opened this issue Apr 5, 2024 · 0 comments
Open

Calculation angle error,My version is 0.07 #49

wyclearnpy opened this issue Apr 5, 2024 · 0 comments

Comments

@wyclearnpy
Copy link

I saw someone asked this question
TypeError Traceback (most recent call last)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1824, in GroupBy.apply(self, func, include_groups, *args, **kwargs)
1823 try:
-> 1824 result = self._python_apply_general(f, self._selected_obj)
1825 if (
1826 not isinstance(self.obj, Series)
1827 and self._selection is None
1828 and self._selected_obj.shape != self._obj_with_exclusions.shape
1829 ):

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1885, in GroupBy._python_apply_general(self, f, data, not_indexed_same, is_transform, is_agg)
1859 """
1860 Apply function f in python space
1861
(...)
1883 data after applying f
1884 """
-> 1885 values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
1886 if not_indexed_same is None:

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\ops.py:919, in BaseGrouper.apply_groupwise(self, f, data, axis)
918 group_axes = group.axes
--> 919 res = f(group)
920 if not mutated and not _is_indexed_like(res, group_axes, axis):

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1809, in GroupBy.apply..f(g)
1807 @wraps(func)
1808 def f(g):
-> 1809 return func(g, *args, **kwargs)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\dlc2kinematics\joint_analysis.py:104, in compute_joint_angles..filter_low_prob(cols, prob)
103 mask = cols.iloc[:, 2] < prob
--> 104 cols.loc[mask, :2] = np.nan
105 return cols

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:907, in _LocationIndexer.setitem(self, key, value)
906 key = self._check_deprecated_callable_usage(key, maybe_callable)
--> 907 indexer = self._get_setitem_indexer(key)
908 self._has_valid_setitem_indexer(key)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:774, in _LocationIndexer._get_setitem_indexer(self, key)
772 with suppress(IndexingError):
773 # suppress "Too many indexers"
--> 774 return self._convert_tuple(key)
776 if isinstance(key, range):
777 # GH#45479 test_loc_setitem_range_key

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in _LocationIndexer._convert_tuple(self, key)
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in (.0)
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:1470, in _LocIndexer._convert_to_indexer(self, key, axis)
1469 if isinstance(key, slice):
-> 1470 return labels._convert_slice_indexer(key, kind="loc")
1472 if (
1473 isinstance(key, tuple)
1474 and not isinstance(labels, MultiIndex)
1475 and self.ndim < 2
1476 and len(key) > 1
1477 ):

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexes\base.py:4275, in Index._convert_slice_indexer(self, key, kind)
4273 if kind == "loc":
4274 # GH#16121, GH#24612, GH#31810
-> 4275 raise TypeError(
4276 "Slicing a positional slice with .loc is not allowed, "
4277 "Use .loc with labels or .iloc with positions instead.",
4278 )
4279 indexer = key

TypeError: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict,
2 dropnan=True, smooth=True, save=False)
3 #you may want to set save=True once you settle on this; so you don't have to recompute.
4
5 #plot:
6 dlc2kinematics.plot_joint_angles(joint_angles)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\dlc2kinematics\joint_analysis.py:107, in compute_joint_angles(df, joints_dict, save, destfolder, output_filename, dropnan, smooth, filter_window, order, pcutoff)
104 cols.loc[mask, :2] = np.nan
105 return cols
--> 107 df = df.groupby("bodyparts", axis=1).apply(filter_low_prob, prob=pcutoff)
109 angle_names = list(joints_dict)
110 if not destfolder:

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1846, in GroupBy.apply(self, func, include_groups, *args, **kwargs)
1830 warnings.warn(
1831 message=_apply_groupings_depr.format(
1832 type(self).name, "apply"
(...)
1835 stacklevel=find_stack_level(),
1836 )
1837 except TypeError:
1838 # gh-20949
1839 # try again, with .apply acting as a filtering
(...)
1843 # fails on some columns, e.g. a numeric operation
1844 # on a string grouper column
-> 1846 return self._python_apply_general(f, self._obj_with_exclusions)
1848 return result

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1885, in GroupBy._python_apply_general(self, f, data, not_indexed_same, is_transform, is_agg)
1850 @Final
1851 def _python_apply_general(
1852 self,
(...)
1857 is_agg: bool = False,
1858 ) -> NDFrameT:
1859 """
1860 Apply function f in python space
1861
(...)
1883 data after applying f
1884 """
-> 1885 values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
1886 if not_indexed_same is None:
1887 not_indexed_same = mutated

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\ops.py:919, in BaseGrouper.apply_groupwise(self, f, data, axis)
917 # group might be modified
918 group_axes = group.axes
--> 919 res = f(group)
920 if not mutated and not _is_indexed_like(res, group_axes, axis):
921 mutated = True

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1809, in GroupBy.apply..f(g)
1807 @wraps(func)
1808 def f(g):
-> 1809 return func(g, *args, **kwargs)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\dlc2kinematics\joint_analysis.py:104, in compute_joint_angles..filter_low_prob(cols, prob)
102 def filter_low_prob(cols, prob):
103 mask = cols.iloc[:, 2] < prob
--> 104 cols.loc[mask, :2] = np.nan
105 return cols

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:907, in _LocationIndexer.setitem(self, key, value)
905 maybe_callable = com.apply_if_callable(key, self.obj)
906 key = self._check_deprecated_callable_usage(key, maybe_callable)
--> 907 indexer = self._get_setitem_indexer(key)
908 self._has_valid_setitem_indexer(key)
910 iloc = self if self.name == "iloc" else self.obj.iloc

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:774, in _LocationIndexer._get_setitem_indexer(self, key)
771 if isinstance(key, tuple):
772 with suppress(IndexingError):
773 # suppress "Too many indexers"
--> 774 return self._convert_tuple(key)
776 if isinstance(key, range):
777 # GH#45479 test_loc_setitem_range_key
778 key = list(key)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in _LocationIndexer._convert_tuple(self, key)
985 @Final
986 def _convert_tuple(self, key: tuple) -> tuple:
987 # Note: we assume _tupleize_axis_indexer has been called, if necessary.
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in (.0)
985 @Final
986 def _convert_tuple(self, key: tuple) -> tuple:
987 # Note: we assume _tupleize_axis_indexer has been called, if necessary.
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:1470, in _LocIndexer._convert_to_indexer(self, key, axis)
1467 labels = self.obj._get_axis(axis)
1469 if isinstance(key, slice):
-> 1470 return labels._convert_slice_indexer(key, kind="loc")
1472 if (
1473 isinstance(key, tuple)
1474 and not isinstance(labels, MultiIndex)
1475 and self.ndim < 2
1476 and len(key) > 1
1477 ):
1478 raise IndexingError("Too many indexers")

File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexes\base.py:4275, in Index._convert_slice_indexer(self, key, kind)
4272 elif is_positional:
4273 if kind == "loc":
4274 # GH#16121, GH#24612, GH#31810
-> 4275 raise TypeError(
4276 "Slicing a positional slice with .loc is not allowed, "
4277 "Use .loc with labels or .iloc with positions instead.",
4278 )
4279 indexer = key
4280 else:

TypeError: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.

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