Skip to content

Commit 187de26

Browse files
committed
TST: python 3 fixes
1 parent 34e8a84 commit 187de26

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

pandas/io/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def _is_url(url):
116116

117117
def _read(cls, filepath_or_buffer, kwds):
118118
"Generic reader of line files."
119+
encoding = kwds.get('encoding', None)
119120

120121
if isinstance(filepath_or_buffer, str) and _is_url(filepath_or_buffer):
121122
from urllib2 import urlopen
@@ -132,7 +133,6 @@ def _read(cls, filepath_or_buffer, kwds):
132133
if hasattr(filepath_or_buffer, 'read'):
133134
f = filepath_or_buffer
134135
else:
135-
encoding = kwds.get('encoding', None)
136136
try:
137137
# universal newline mode
138138
f = com._get_handle(filepath_or_buffer, 'U', encoding=encoding)

pandas/io/sql.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def tquery(sql, con=None, cur=None, retry=True):
8787
return tquery(sql, con=con, retry=False)
8888

8989
if result and len(result[0]) == 1:
90-
result = list(zip(*result)[0])
90+
# python 3 compat
91+
result = list(list(zip(*result))[0])
9192
elif result is None: # pragma: no cover
9293
result = []
9394

pandas/stats/tests/test_math.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717
N, K = 100, 10
1818

19+
_have_statsmodels = True
20+
try:
21+
import statsmodels.api as sm
22+
except ImportError:
23+
try:
24+
import scikits.statsmodels.api as sm
25+
except ImportError:
26+
_have_statsmodels = False
1927

2028
class TestMath(unittest.TestCase):
2129

@@ -39,6 +47,9 @@ def test_rank_1d(self):
3947
self.assertEqual(0, pmath.rank(Series(0, self.series.index)))
4048

4149
def test_solve_rect(self):
50+
if not _have_statsmodels:
51+
raise nose.SkipTest
52+
4253
b = Series(np.random.randn(N), self.frame.index)
4354
result = pmath.solve(self.frame, b)
4455
expected = ols(y=b, x=self.frame, intercept=False).beta

pandas/tests/test_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ def test_operators_none_as_na(self):
21402140
df = DataFrame({"col1": [2,5.0,123,None],
21412141
"col2": [1,2,3,4]})
21422142

2143-
ops = [operator.add, operator.sub, operator.mul, operator.div]
2143+
ops = [operator.add, operator.sub, operator.mul, operator.truediv]
21442144

21452145
for op in ops:
21462146
filled = df.fillna(np.nan)

0 commit comments

Comments
 (0)