soft-matter / trackpy-examples

sample images, examples, and speed tests for trackpy
Other
21 stars 42 forks source link

Error in the walkthrough #42

Closed caburj closed 7 years ago

caburj commented 7 years ago

I forked the trackpy repo and installed the package using python setup.py develop in anaconda3. While going through the walkthrough notebook, I encountered the error below. Is there something wrong in my installation? I'm running this in a 32-bit Ubuntu virtual machine with Anaconda3-4.4.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-27-2822576c24b1> in <module>()
----> 1 d = tp.compute_drift(t1)

/home/joseph/codes/trackpy/trackpy/motion.py in compute_drift(traj, smoothing, pos_columns)
    270     del delta['frame']
    271     delta.reset_index('particle', drop=True, inplace=True)
--> 272     delta.reset_index('frame', drop=False, inplace=True)
    273     dx = delta.groupby('frame').mean()
    274     if smoothing > 0:

/home/joseph/anaconda3/envs/trackpy-env/lib/python3.6/site-packages/pandas/core/frame.py in reset_index(self, level, drop, inplace, col_level, col_fill)
   3053                 # to ndarray and maybe infer different dtype
   3054                 level_values = _maybe_casted_values(lev, lab)
-> 3055                 if level is None or i in level:
   3056                     new_obj.insert(0, name, level_values)
   3057 

TypeError: 'in <string>' requires string as left operand, not int
caspervdw commented 7 years ago

This is an issue that has to do with pandas 0.20.1. Either update or downgrade pandas and the error should disappear.

caburj commented 7 years ago

You were right thatI was using pandas 0.20.1. After updating it, the walkthrough notebook ran perfectly. Thank you!

caspervdw commented 7 years ago

You're welcome! Thanks for submitting the issue.