Skip to content

Clean up py36 build #14979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/requirements-3.6.run
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-dateutil
pytz
numpy
scipy
6 changes: 4 additions & 2 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ def is_in_obj(gpr):
"Defaulting to column but "
"this will raise an ambiguity error in a "
"future version") % gpr,
FutureWarning, stacklevel=2)
FutureWarning, stacklevel=5)
in_axis, name, gpr = True, gpr, obj[gpr]
exclusions.append(name)
elif gpr in obj.index.names:
Expand Down Expand Up @@ -4025,7 +4025,9 @@ def __iter__(self):
sdata = self._get_sorted_data()

if self.ngroups == 0:
raise StopIteration
# we are inside a generator, rather than raise StopIteration
# we merely return signal the end
return

starts, ends = lib.generate_slices(self.slabels, self.ngroups)

Expand Down
14 changes: 10 additions & 4 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,20 @@ def _read(filepath_or_buffer, kwds):
raise NotImplementedError("'nrows' and 'chunksize' cannot be used"
" together yet.")
elif nrows is not None:
data = parser.read(nrows)
parser.close()
try:
data = parser.read(nrows)
finally:
parser.close()
return data

elif chunksize or iterator:
return parser

data = parser.read()
parser.close()
try:
data = parser.read()
finally:
parser.close()

return data

_parser_defaults = {
Expand Down
7 changes: 5 additions & 2 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,13 @@ def read_stata(filepath_or_buffer, convert_dates=True,
if iterator or chunksize:
data = reader
else:
data = reader.read()
reader.close()
try:
data = reader.read()
finally:
reader.close()
return data


_date_formats = ["%tc", "%tC", "%td", "%d", "%tw", "%tm", "%tq", "%th", "%ty"]


Expand Down
4 changes: 2 additions & 2 deletions pandas/io/tests/parser/test_unsupported.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def test_c_engine(self):
msg = 'Error tokenizing data'

with tm.assertRaisesRegexp(ParserError, msg):
read_table(StringIO(text), sep='\s+')
read_table(StringIO(text), sep='\\s+')
with tm.assertRaisesRegexp(ParserError, msg):
read_table(StringIO(text), engine='c', sep='\s+')
read_table(StringIO(text), engine='c', sep='\\s+')

msg = "Only length-1 thousands markers supported"
data = """A|B|C
Expand Down
4 changes: 2 additions & 2 deletions pandas/sparse/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_astype(self):
arr.astype('i8')

arr = SparseArray([0, np.nan, 0, 1], fill_value=0)
msg = 'Cannot convert non-finite values \(NA or inf\) to integer'
msg = 'Cannot convert non-finite values \\(NA or inf\\) to integer'
with tm.assertRaisesRegexp(ValueError, msg):
arr.astype('i8')

Expand Down Expand Up @@ -708,7 +708,7 @@ def test_cumsum(self):
tm.assert_sp_array_equal(out, expected)

axis = 1 # SparseArray currently 1-D, so only axis = 0 is valid.
msg = "axis\(={axis}\) out of bounds".format(axis=axis)
msg = "axis\\(={axis}\\) out of bounds".format(axis=axis)
with tm.assertRaisesRegexp(ValueError, msg):
SparseArray(data).cumsum(axis=axis)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def test_astype_cast_nan_inf_int(self):
# GH14265, check nan and inf raise error when converting to int
types = [np.int32, np.int64]
values = [np.nan, np.inf]
msg = 'Cannot convert non-finite values \(NA or inf\) to integer'
msg = 'Cannot convert non-finite values \\(NA or inf\\) to integer'

for this_type in types:
for this_val in values:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_astype_cast_nan_inf_int(self):
# GH14265, check nan and inf raise error when converting to int
types = [np.int32, np.int64]
values = [np.nan, np.inf]
msg = 'Cannot convert non-finite values \(NA or inf\) to integer'
msg = 'Cannot convert non-finite values \\(NA or inf\\) to integer'

for this_type in types:
for this_val in values:
Expand Down
29 changes: 17 additions & 12 deletions pandas/tools/tests/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,26 @@ def _check_output(result, values_col, index=['A', 'B'],
df = df.set_index(['JOB', 'NAME', 'YEAR', 'MONTH'], drop=False,
append=False)

result = df.pivot_table(index=['JOB', 'NAME'],
columns=['YEAR', 'MONTH'],
values=['DAYS', 'SALARY'],
aggfunc={'DAYS': 'mean', 'SALARY': 'sum'},
margins=True)

expected = df.pivot_table(index=['JOB', 'NAME'],
columns=['YEAR', 'MONTH'], values=['DAYS'],
aggfunc='mean', margins=True)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
result = df.pivot_table(index=['JOB', 'NAME'],
columns=['YEAR', 'MONTH'],
values=['DAYS', 'SALARY'],
aggfunc={'DAYS': 'mean', 'SALARY': 'sum'},
margins=True)

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
expected = df.pivot_table(index=['JOB', 'NAME'],
columns=['YEAR', 'MONTH'],
values=['DAYS'],
aggfunc='mean', margins=True)

tm.assert_frame_equal(result['DAYS'], expected['DAYS'])

expected = df.pivot_table(index=['JOB', 'NAME'],
columns=['YEAR', 'MONTH'], values=['SALARY'],
aggfunc='sum', margins=True)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
expected = df.pivot_table(index=['JOB', 'NAME'],
columns=['YEAR', 'MONTH'],
values=['SALARY'],
aggfunc='sum', margins=True)

tm.assert_frame_equal(result['SALARY'], expected['SALARY'])

Expand Down