@@ -732,7 +732,7 @@ def construct_from_string(cls, string: str_type):
732
732
datetime64[ns, UTC]
733
733
"""
734
734
if isinstance (string , str ):
735
- msg = "Could not construct DatetimeTZDtype from '{string}'"
735
+ msg = f"Cannot construct a ' DatetimeTZDtype' from '{ string } '"
736
736
match = cls ._match .match (string )
737
737
if match :
738
738
d = match .groupdict ()
@@ -743,10 +743,10 @@ def construct_from_string(cls, string: str_type):
743
743
# pytz timezone (actually pytz.UnknownTimeZoneError).
744
744
# TypeError if we pass a nonsense tz;
745
745
# ValueError if we pass a unit other than "ns"
746
- raise TypeError (msg . format ( string = string ) ) from err
747
- raise TypeError (msg . format ( string = string ) )
746
+ raise TypeError (msg ) from err
747
+ raise TypeError (msg )
748
748
749
- raise TypeError ("Could not construct DatetimeTZDtype" )
749
+ raise TypeError ("Cannot construct a ' DatetimeTZDtype' " )
750
750
751
751
def __str__ (self ) -> str_type :
752
752
return "datetime64[{unit}, {tz}]" .format (unit = self .unit , tz = self .tz )
@@ -883,7 +883,7 @@ def construct_from_string(cls, string):
883
883
return cls (freq = string )
884
884
except ValueError :
885
885
pass
886
- raise TypeError ("could not construct PeriodDtype" )
886
+ raise TypeError (f"Cannot construct a ' PeriodDtype' from ' { string } ' " )
887
887
888
888
def __str__ (self ) -> str_type :
889
889
return self .name
@@ -1054,6 +1054,7 @@ def construct_from_string(cls, string):
1054
1054
return cls (string )
1055
1055
1056
1056
msg = (
1057
+ f"Cannot construct a 'IntervalDtype' from '{ string } '.\n \n "
1057
1058
"Incorrectly formatted string passed to constructor. "
1058
1059
"Valid formats include Interval or Interval[dtype] "
1059
1060
"where dtype is numeric, datetime, or timedelta"
0 commit comments