@@ -1356,18 +1356,31 @@ def __init__(
1356
1356
self .fill_method = fill_method
1357
1357
self .limit = limit
1358
1358
1359
- if origin in {"epoch" , "start_day " , "start " }:
1359
+ if origin in {"epoch" , "start " , "start_day " }:
1360
1360
self .origin = origin
1361
1361
else :
1362
- self .origin = Timestamp (origin )
1363
- self .offset = Timedelta (offset ) if offset is not None else None
1362
+ try :
1363
+ self .origin = Timestamp (origin )
1364
+ except Exception as e :
1365
+ raise ValueError (
1366
+ "'origin' should be equal to 'epoch', 'start', 'start_day' or "
1367
+ f"should be a Timestamp convertible type. Got '{ origin } ' instead."
1368
+ ) from e
1369
+
1370
+ try :
1371
+ self .offset = Timedelta (offset ) if offset is not None else None
1372
+ except Exception as e :
1373
+ raise ValueError (
1374
+ "'offset' should be a Timedelta convertible type. "
1375
+ f"Got '{ offset } ' instead."
1376
+ ) from e
1364
1377
1365
1378
# always sort time groupers
1366
1379
kwargs ["sort" ] = True
1367
1380
1368
1381
# Handle deprecated arguments since v1.1.0 of `base` and `loffset` (GH #31809)
1369
1382
if base is not None and offset is not None :
1370
- raise ValueError ("` offset` and ` base` cannot be present at the same time" )
1383
+ raise ValueError ("' offset' and ' base' cannot be present at the same time" )
1371
1384
1372
1385
if base and isinstance (freq , Tick ):
1373
1386
# this conversion handle the default behavior of base and the
@@ -1584,8 +1597,8 @@ def _get_period_bins(self, ax):
1584
1597
bin_shift = 0
1585
1598
1586
1599
if isinstance (self .freq , Tick ):
1587
- # GH 23882 & 31809: get adjusted bin edge labels with ` origin`
1588
- # and ` origin` support. This call only makes sense if the freq is a
1600
+ # GH 23882 & 31809: get adjusted bin edge labels with ' origin'
1601
+ # and ' origin' support. This call only makes sense if the freq is a
1589
1602
# Tick since offset and origin are only used in those cases.
1590
1603
# Not doing this check could create an extra empty bin.
1591
1604
p_start , end = _get_period_range_edges (
0 commit comments