Closed jmcclimo2003 closed 5 months ago
Thanks for reporting this. This looks like the issue that's fixed in the development version of trackpy, and that will be in v0.6.2 coming in the next few weeks. The installation instructions in the documentation describe how to install the development version. You will first need to uninstall the version you have, but otherwise it should be straightforward.
On Jan 26, 2024, at 3:40 PM, jmcclimo2003 @.***> wrote:
Hi there, new to TrackPy. I have been running the tutorial verbatim, entering every line in a Jupyter Notebook, and I ran into the following problem with the emsd() command:
em = tp.emsd(tm, 100/285., 24) # microns per pixel = 100/285., frames per second = 24
which gives the following error: `--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[64], line 1 ----> 1 em = tp.emsd(tm, 100/285., 24)
File ~\anaconda3\Lib\site-packages\trackpy\motion.py:235, in emsd(traj, mpp, fps, max_lagtime, detail, pos_columns) 233 ids.append(pid) 234 msds = pandas_concat(msds, keys=ids, names=['particle', 'frame']) --> 235 results = msds.mul(msds['N'], axis=0).mean(level=1) # weighted average 236 results = results.div(msds['N'].mean(level=1), axis=0) # weights normalized 237 # Above, lagt is lumped in with the rest for simplicity and speed. 238 # Here, rebuild it from the frame index.
File ~\anaconda3\Lib\site-packages\pandas\core\frame.py:11335, in DataFrame.mean(self, axis, skipna, numeric_only, kwargs) 11327 @dochttps://github.com/doc(make_doc("mean", ndim=2)) 11328 def mean( 11329 self, (...) 11333 kwargs, 11334 ):
11335 result = super().mean(axis, skipna, numeric_only, **kwargs) 11336 if isinstance(result, Series): 11337 result = result.finalize(self, method="mean")
File ~\anaconda3\Lib\site-packages\pandas\core\generic.py:11992, in NDFrame.mean(self, axis, skipna, numeric_only, kwargs) 11985 def mean( 11986 self, 11987 axis: Axis | None = 0, (...) 11990 kwargs, 11991 ) -> Series | float:
11992 return self._stat_function( 11993 "mean", nanops.nanmean, axis, skipna, numeric_only, **kwargs 11994 )
File ~\anaconda3\Lib\site-packages\pandas\core\generic.py:11945, in NDFrame._stat_function(self, name, func, axis, skipna, numeric_only, kwargs) 11934 @Finalhttps://github.com/Final 11935 def _stat_function( 11936 self, (...) 11942 kwargs, 11943 ): 11944 assert name in ["median", "mean", "min", "max", "kurt", "skew"], name
11945 nv.validate_func(name, (), kwargs) 11947 validate_bool_kwarg(skipna, "skipna", none_allowed=False) 11949 return self._reduce( 11950 func, name=name, axis=axis, skipna=skipna, numeric_only=numeric_only 11951 )
File ~\anaconda3\Lib\site-packages\pandas\compat\numpy\function.py:416, in validate_func(fname, args, kwargs) 413 return validate_stat_func(args, kwargs, fname=fname) 415 validation_func = _validation_funcs[fname] --> 416 return validation_func(args, kwargs)
File ~\anaconda3\Lib\site-packages\pandas\compat\numpy\function.py:88, in CompatValidator.call(self, args, kwargs, fname, max_fname_arg_count, method) 86 validate_kwargs(fname, kwargs, self.defaults) 87 elif method == "both": ---> 88 validate_args_and_kwargs( 89 fname, args, kwargs, max_fname_arg_count, self.defaults 90 ) 91 else: 92 raise ValueError(f"invalid validation method '{method}'")
File ~\anaconda3\Lib\site-packages\pandas\util_validators.py:223, in validate_args_and_kwargs(fname, args, kwargs, max_fname_arg_count, compat_args) 218 raise TypeError( 219 f"{fname}() got multiple values for keyword argument '{key}'" 220 ) 222 kwargs.update(args_dict) --> 223 validate_kwargs(fname, kwargs, compat_args)
File ~\anaconda3\Lib\site-packages\pandas\util_validators.py:164, in validate_kwargs(fname, kwargs, compat_args) 142 """ 143 Checks whether parameters passed to the *kwargs argument in a 144 function fname are valid parameters as specified in compat_args (...) 161 map to the default values specified in compat_args 162 """ 163 kwds = kwargs.copy() --> 164 _check_for_invalid_keys(fname, kwargs, compat_args) 165 _check_for_default_values(fname, kwds, compat_args)
File ~\anaconda3\Lib\site-packages\pandas\util_validators.py:138, in _check_for_invalid_keys(fname, kwargs, compat_args) 136 if diff: 137 bad_arg = next(iter(diff)) --> 138 raise TypeError(f"{fname}() got an unexpected keyword argument '{bad_arg}'")
TypeError: mean() got an unexpected keyword argument 'level'`
I think this is some incompatibility with the newest pandas. I am trying to install an older pandas, but not below 1.0 are compatible with my current python 3.11? Is there a known fix for this, or a silly mistake on my part?
— Reply to this email directly, view it on GitHubhttps://github.com/soft-matter/trackpy/issues/750, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAWY23JGHA2RIHRGUTK24JLYQQIDDAVCNFSM6AAAAABCMWJT76VHI2DSMVQWIX3LMV43ASLTON2WKOZSGEYDEOBXGA2TCNY. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thank you, the development version fixed the issue and let me finish the tutorial. I will try the development package next time before reporting an issue to make sure you haven't fixed it already.
Hi there, new to TrackPy. I have been running the tutorial verbatim, entering every line in a Jupyter Notebook, and I ran into the following problem with the emsd() command:
em = tp.emsd(tm, 100/285., 24) # microns per pixel = 100/285., frames per second = 24
which gives the following error: `--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[64], line 1 ----> 1 em = tp.emsd(tm, 100/285., 24)
File ~\anaconda3\Lib\site-packages\trackpy\motion.py:235, in emsd(traj, mpp, fps, max_lagtime, detail, pos_columns) 233 ids.append(pid) 234 msds = pandas_concat(msds, keys=ids, names=['particle', 'frame']) --> 235 results = msds.mul(msds['N'], axis=0).mean(level=1) # weighted average 236 results = results.div(msds['N'].mean(level=1), axis=0) # weights normalized 237 # Above, lagt is lumped in with the rest for simplicity and speed. 238 # Here, rebuild it from the frame index.
File ~\anaconda3\Lib\site-packages\pandas\core\frame.py:11335, in DataFrame.mean(self, axis, skipna, numeric_only, kwargs) 11327 @doc(make_doc("mean", ndim=2)) 11328 def mean( 11329 self, (...) 11333 kwargs, 11334 ):
File ~\anaconda3\Lib\site-packages\pandas\core\generic.py:11992, in NDFrame.mean(self, axis, skipna, numeric_only, kwargs) 11985 def mean( 11986 self, 11987 axis: Axis | None = 0, (...) 11990 kwargs, 11991 ) -> Series | float:
File ~\anaconda3\Lib\site-packages\pandas\core\generic.py:11945, in NDFrame._stat_function(self, name, func, axis, skipna, numeric_only, kwargs) 11934 @final 11935 def _stat_function( 11936 self, (...) 11942 kwargs, 11943 ): 11944 assert name in ["median", "mean", "min", "max", "kurt", "skew"], name
File ~\anaconda3\Lib\site-packages\pandas\compat\numpy\function.py:416, in validate_func(fname, args, kwargs) 413 return validate_stat_func(args, kwargs, fname=fname) 415 validation_func = _validation_funcs[fname] --> 416 return validation_func(args, kwargs)
File ~\anaconda3\Lib\site-packages\pandas\compat\numpy\function.py:88, in CompatValidator.call(self, args, kwargs, fname, max_fname_arg_count, method) 86 validate_kwargs(fname, kwargs, self.defaults) 87 elif method == "both": ---> 88 validate_args_and_kwargs( 89 fname, args, kwargs, max_fname_arg_count, self.defaults 90 ) 91 else: 92 raise ValueError(f"invalid validation method '{method}'")
File ~\anaconda3\Lib\site-packages\pandas\util_validators.py:223, in validate_args_and_kwargs(fname, args, kwargs, max_fname_arg_count, compat_args) 218 raise TypeError( 219 f"{fname}() got multiple values for keyword argument '{key}'" 220 ) 222 kwargs.update(args_dict) --> 223 validate_kwargs(fname, kwargs, compat_args)
File ~\anaconda3\Lib\site-packages\pandas\util_validators.py:164, in validate_kwargs(fname, kwargs, compat_args) 142 """ 143 Checks whether parameters passed to the *kwargs argument in a 144 function
fname
are valid parameters as specified in `compat_args(...) 161 map to the default values specified in
compat_args` 162 """ 163 kwds = kwargs.copy() --> 164 _check_for_invalid_keys(fname, kwargs, compat_args) 165 _check_for_default_values(fname, kwds, compat_args)File ~\anaconda3\Lib\site-packages\pandas\util_validators.py:138, in _check_for_invalid_keys(fname, kwargs, compat_args) 136 if diff: 137 bad_arg = next(iter(diff)) --> 138 raise TypeError(f"{fname}() got an unexpected keyword argument '{bad_arg}'")
TypeError: mean() got an unexpected keyword argument 'level'`
I think this is some incompatibility with the newest pandas. I am trying to install an older pandas, but not below 1.0 are compatible with my current python 3.11? Is there a known fix for this, or a silly mistake on my part?