Skip to content

Commit

Permalink
Fixes so more tests pass on Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver authored and wesm committed Oct 9, 2011
1 parent 550371d commit 16dbeab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
3 changes: 3 additions & 0 deletions pandas/core/frame.py
Expand Up @@ -278,6 +278,9 @@ def iteritems(self):
"""Iterator over (column, series) pairs"""
series = self._series
return ((k, series[k]) for k in self.columns)

if py3compat.PY3:
items = iteritems

def __len__(self):
"""Returns length of index"""
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/series.py
Expand Up @@ -419,6 +419,9 @@ def iteritems(self):
Lazily iterate over (index, value) tuples
"""
return itertools.izip(iter(self.index), iter(self))

if py3compat.PY3:
items = iteritems

#----------------------------------------------------------------------
# Arithmetic operators
Expand Down
34 changes: 17 additions & 17 deletions pandas/tests/test_frame.py
Expand Up @@ -2414,23 +2414,23 @@ def test_combine_first(self):
assert_frame_equal(comb, self.frame)

def test_combine_first_mixed_bug(self):
idx = Index(['a','b','c','e'])
ser1 = Series([5.0,-9.0,4.0,100.],index=idx)
ser2 = Series(['a', 'b', 'c', 'e'], index=idx)
ser3 = Series([12,4,5,97], index=idx)

frame1 = DataFrame({"col0" : ser1,
"col2" : ser2,
"col3" : ser3})

idx = Index(['a','b','c','f'])
ser1 = Series([5.0,-9.0,4.0,100.], index=idx)
ser2 = Series(['a','b','c','f'], index=idx)
ser3 = Series([12,4,5,97],index=idx)

frame2 = DataFrame({"col1" : ser1,
"col2" : ser2,
"col5" : ser3})
idx = Index(['a','b','c','e'])
ser1 = Series([5.0,-9.0,4.0,100.],index=idx)
ser2 = Series(['a', 'b', 'c', 'e'], index=idx)
ser3 = Series([12,4,5,97], index=idx)

frame1 = DataFrame({"col0" : ser1,
"col2" : ser2,
"col3" : ser3})

idx = Index(['a','b','c','f'])
ser1 = Series([5.0,-9.0,4.0,100.], index=idx)
ser2 = Series(['a','b','c','f'], index=idx)
ser3 = Series([12,4,5,97],index=idx)

frame2 = DataFrame({"col1" : ser1,
"col2" : ser2,
"col5" : ser3})


combined = frame1.combine_first(frame2)
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/testing.py
Expand Up @@ -31,7 +31,7 @@
K = 4

def rands(n):
choices = string.letters + string.digits
choices = string.ascii_letters + string.digits
return ''.join([random.choice(choices) for _ in xrange(n)])

#-------------------------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions setup.py
Expand Up @@ -295,13 +295,15 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
'pandas.io',
'pandas.sandbox',
'pandas.stats',
'pandas.util'],
package_data={'pandas' : ['tests/*.py'],
'pandas.io' : ['tests/*.py',
'tests/*.h5',
'pandas.util',
'pandas.tests',
'pandas.io.tests',
'pandas.stats.tests',
],
package_data={'pandas.io' : ['tests/*.h5',
'tests/*.csv',
'tests/*.xls'],
'pandas.stats' : ['tests/*.py']},
},
ext_modules=extensions,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
Expand Down

0 comments on commit 16dbeab

Please sign in to comment.