AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.03k stars 11.31k forks source link

#79 Using the iteritems() method for grabbing the data from a Series … #81

Closed gbremer closed 7 years ago

gbremer commented 7 years ago

…when updating data in a _DictWrapper class. The pandas 0.20.3 release for Python 2.7 does not have an items() method while the release Python 3.7 does, and both versions have iteritems() which provides the data in the proper format.

The chap03ex notebook works with this code in Py27 and Py36. The thinkstats2_test module passes in both Py27 and Py36.

Mike:code gbremer$ python -V
Python 2.7.13 :: Continuum Analytics, Inc.
Mike:code gbremer$ python thinkstats2_test.py
..[ 0.16666667  0.33333333  0.66666667  0.66666667  0.83333333  1.        ]
........................
----------------------------------------------------------------------
Ran 26 tests in 0.303s

OK
Python 3.6.2 :: Continuum Analytics, Inc.
Mike:code gbremer$ python thinkstats2_test.py
..[ 0.16666667  0.33333333  0.66666667  0.66666667  0.83333333  1.        ]
.................../Users/gbremer/projects/ThinkStats2/code/thinkstats2.py:2646: ResourceWarning: unclosed file <_io.TextIOWrapper name='2002FemPreg.dct' mode='r' encoding='UTF-8'>
  for line in open(dct_file, **options):
.....
----------------------------------------------------------------------
Ran 26 tests in 0.221s

OK
AllenDowney commented 7 years ago

Thanks!