We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 009ffa8 commit 5cb5cf9Copy full SHA for 5cb5cf9
pandas/core/dtypes/cast.py
@@ -2,6 +2,7 @@
2
Routines for casting.
3
"""
4
5
+from contextlib import suppress
6
from datetime import date, datetime, timedelta
7
from typing import (
8
TYPE_CHECKING,
@@ -191,12 +192,10 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
191
192
# TODO(DatetimeArray): merge with previous elif
193
from pandas.core.arrays import PeriodArray
194
- try:
195
- return PeriodArray(result, freq=dtype.freq)
196
- except TypeError:
+ with suppress(TypeError):
197
# e.g. TypeError: int() argument must be a string, a
198
# bytes-like object or a number, not 'Period
199
- pass
+ return PeriodArray(result, freq=dtype.freq)
200
201
return result
202
0 commit comments