UDST / synthpop

Synthetic populations from census data
BSD 3-Clause "New" or "Revised" License
99 stars 47 forks source link

Need to use older versions of panda #54

Closed MGrunnill closed 4 years ago

MGrunnill commented 4 years ago

I am trying the notebook demo simple_synthesis and the 3rd cell gives the following error:


RuntimeError Traceback (most recent call last)

in ----> 1 hh_marg, p_marg, hh_sample, p_sample, xwalk = zs.load_data(hh_marginal_file, person_marginal_file, hh_sample_file, person_sample_file)

~\AppData\Local\Continuum\anaconda3\envs\synthpop\lib\site-packages\synthpop-0.1.1-py3.7.egg\synthpop\zone_synthesizer.py in load_data(hh_marginal_file, person_marginal_file, hh_sample_file, person_sample_file) 40 41 hh_marg = pd.read_csv(hh_marginal_file, header=[0, 1], index_col=0) ---> 42 hh_marg.columns.levels[0].name = 'cat_name' 43 hh_marg.columns.levels[1].name = 'cat_values' 44

~\AppData\Local\Continuum\anaconda3\envs\synthpop\lib\site-packages\pandas-1.0.3-py3.7-win-amd64.egg\pandas\core\indexes\base.py in name(self, value) 1189 # Used in MultiIndex.levels to avoid silently ignoring name updates. 1190 raise RuntimeError( -> 1191 "Cannot set name on a level of a MultiIndex. Use " 1192 "'MultiIndex.set_names' instead." 1193 )

RuntimeError: Cannot set name on a level of a MultiIndex. Use 'MultiIndex.set_names' instead.

I am guessing in an older version of pandas the lines below in the function

42: hh_marg.columns.levels[0].name = 'cat_name' 43: hh_marg.columns.levels[1].name = 'cat_values' 49:p_marg.columns.levels[0].name = 'MultiIndex.set_names' 50:p_marg.columns.levels[1].name = 'cat_values'

Removing them seems to cause things to work with Pandas version 1.03.