-
Notifications
You must be signed in to change notification settings - Fork 132
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
tp.emsd TypeError: mean() got an unexpected keyword argument 'level' #738
Comments
Seeing this : From the pandas documentation :
|
Which version of pandas is compatible with trackpy 0.6.0rc1? |
Thanks for reporting this! Pandas 1.3 is the most recent version that I'm certain trackpy works with. This needs a pull request, or a working version of that line of code. |
These are the only changes needed, both in I changed them in my own copy of |
That's great! Thank you!! |
I think PR #735 might be related too. |
I have submitted a pull request (#742) with this edit. |
Trying to use the emsd function.
em = tp.emsd(tm, microns_per_pixel, frames_per_second)
But got following error, I'm pretty new Python to and don't know where start to fix this error. Any advice appreciated!
TypeError Traceback (most recent call last)
Cell In[122], line 1
----> 1 em = tp.emsd(tm, microns_per_pixel, frames_per_second) # microns per pixel = 100/285., frames per second = 24
2 fig, ax = plt.subplots()
3 ax.plot(em.index, em, 'o')
File ~\AppData\Local\Programs\Python\Python311\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 ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\generic.py:11556, in NDFrame._add_numeric_operations..mean(self, axis, skipna, numeric_only, **kwargs)
11539 @doc(
11540 _num_doc,
11541 desc="Return the mean of the values over the requested axis.",
(...)
11554 **kwargs,
11555 ):
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\generic.py:11201, in NDFrame.mean(self, axis, skipna, numeric_only, **kwargs)
11194 def mean(
11195 self,
11196 axis: Axis | None = 0,
(...)
11199 **kwargs,
11200 ) -> Series | float:
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\generic.py:11154, in NDFrame._stat_function(self, name, func, axis, skipna, numeric_only, **kwargs)
11152 nv.validate_median((), kwargs)
11153 else:
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\compat\numpy\function.py:80, in CompatValidator.call(self, args, kwargs, fname, max_fname_arg_count, method)
78 validate_args(fname, args, max_fname_arg_count, self.defaults)
79 elif method == "kwargs":
---> 80 validate_kwargs(fname, kwargs, self.defaults)
81 elif method == "both":
82 validate_args_and_kwargs(
83 fname, args, kwargs, max_fname_arg_count, self.defaults
84 )
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\util_validators.py:162, in validate_kwargs(fname, kwargs, compat_args)
140 """
141 Checks whether parameters passed to the **kwargs argument in a
142 function
fname
are valid parameters as specified in*compat_args
(...)
159 map to the default values specified in
compat_args
160 """
161 kwds = kwargs.copy()
--> 162 _check_for_invalid_keys(fname, kwargs, compat_args)
163 _check_for_default_values(fname, kwds, compat_args)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\util_validators.py:136, in _check_for_invalid_keys(fname, kwargs, compat_args)
134 if diff:
135 bad_arg = list(diff)[0]
--> 136 raise TypeError(f"{fname}() got an unexpected keyword argument '{bad_arg}'")
TypeError: mean() got an unexpected keyword argument 'level'
The text was updated successfully, but these errors were encountered: