openworm / tracker-commons

Compilation of information and code bases related to open-source trackers for C. elegans
11 stars 12 forks source link

Python wcon pip incompatibility with latest Python 3 pandas #171

Open cheelee opened 5 years ago

cheelee commented 5 years ago

This is probably related to the issue of dependencies and version control raised in #168 .

Attempts to load what should be a well-formed WCON file - https://zenodo.org/record/1034927/files/unc-80%20(e1069)%20nRHO-1%20QT309%20on%20food%20L_2011_11_11__13_12___3___4.wcon.zip fails with the following error:

(env) Arya:test-wcon cheelee$ time python read.py 
Loading file: ../static/example.wcon
Traceback (most recent call last):
  File "read.py", line 3, in <module>
    w1 = WCONWorms.load_from_file('../static/example.wcon')
  File "/Volumes/OpenWorm/repository/git/sandbox/nwb-explorer/env/lib/python3.6/site-packages/wcon/wcon_parser.py", line 605, in load_from_file
    w_current = cls.load(infile, validate_against_schema)
  File "/Volumes/OpenWorm/repository/git/sandbox/nwb-explorer/env/lib/python3.6/site-packages/wcon/wcon_parser.py", line 710, in load
    w._data = parse_data(root['data'])
  File "/Volumes/OpenWorm/repository/git/sandbox/nwb-explorer/env/lib/python3.6/site-packages/wcon/wcon_data.py", line 320, in parse_data
    df_odict = _obtain_time_series_data_frame(data)
  File "/Volumes/OpenWorm/repository/git/sandbox/nwb-explorer/env/lib/python3.6/site-packages/wcon/wcon_data.py", line 405, in _obtain_time_series_data_frame
    cur_df.index.names = 't'
  File "/Volumes/OpenWorm/repository/git/sandbox/nwb-explorer/env/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 1335, in _set_names
    raise ValueError('Names must be a list-like')
ValueError: Names must be a list-like

This appears to be fixed by replacing the offending line cur_df.index.names = 't' with cur_df.index.names = ['t'] but we'd need to figure out if this is the result of deprecation, and if so after which version of pandas.

cheelee commented 4 years ago

Update: This appears to be another deprecated feature this time transitioning from pandas 0.19.0 onward.

Idea - for previous release, enforce and test dependency. For future version, fix to accommodate new requirements by pandas.

Edit: Source of the above information - https://github.com/pandas-dev/pandas/issues/21340