Skip to content

CLN: more Exceptions #28642

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

Merged
merged 1 commit into from
Sep 27, 2019
Merged
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
2 changes: 1 addition & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def wrap_results(self):
results = self.results

# see if we can infer the results
if len(results) > 0 and is_sequence(results[0]):
if len(results) > 0 and 0 in results and is_sequence(results[0]):

return self.wrap_results_for_axis()

Expand Down
5 changes: 3 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,8 +2588,9 @@ def intersection(self, other, sort=False):
try:
indexer = Index(rvals).get_indexer(lvals)
indexer = indexer.take((indexer != -1).nonzero()[0])
except Exception:
# duplicates
except (InvalidIndexError, IncompatibleFrequency):
# InvalidIndexError raised by get_indexer if non-unique
# IncompatibleFrequency raised by PeriodIndex.get_indexer
indexer = algos.unique1d(Index(rvals).get_indexer_non_unique(lvals)[0])
indexer = indexer[indexer != -1]

Expand Down
5 changes: 1 addition & 4 deletions pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,10 +1591,7 @@ def execute(self, *args, **kwargs):
else:
cur = self.con.cursor()
try:
if kwargs:
cur.execute(*args, **kwargs)
else:
cur.execute(*args)
cur.execute(*args, **kwargs)
return cur
except Exception as exc:
try:
Expand Down
18 changes: 9 additions & 9 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2388,16 +2388,16 @@ def write_file(self):
self._write_map()
except Exception as exc:
self._close()
try:
if self._own_file:
if self._own_file:
try:
os.unlink(self._fname)
except Exception:
warnings.warn(
"This save was not successful but {0} could not "
"be deleted. This file is not "
"valid.".format(self._fname),
ResourceWarning,
)
except OSError:
warnings.warn(
"This save was not successful but {0} could not "
"be deleted. This file is not "
"valid.".format(self._fname),
ResourceWarning,
)
raise exc
else:
self._close()
Expand Down