Skip to content

Commit 80f68b2

Browse files
author
Vipul Rai
committed
resolves series.py issue pandas-dev#33327
1 parent 3ed7dff commit 80f68b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/core/series.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,8 @@ def to_timestamp(self, freq=None, how="start", copy=True) -> "Series":
46614661
if copy:
46624662
new_values = new_values.copy()
46634663

4664-
assert isinstance(self.index, (ABCDatetimeIndex, ABCPeriodIndex))
4664+
if not isinstance(self.index, (ABCDatetimeIndex, ABCPeriodIndex)):
4665+
raise TypeError(f"unsupported Type {self.index}")
46654666
new_index = self.index.to_timestamp(freq=freq, how=how)
46664667
return self._constructor(new_values, index=new_index).__finalize__(
46674668
self, method="to_timestamp"
@@ -4688,7 +4689,8 @@ def to_period(self, freq=None, copy=True) -> "Series":
46884689
if copy:
46894690
new_values = new_values.copy()
46904691

4691-
assert isinstance(self.index, ABCDatetimeIndex)
4692+
if not isinstance(self.index, ABCDatetimeIndex):
4693+
raise TypeError(f"unsupported Type {self.index}")
46924694
new_index = self.index.to_period(freq=freq)
46934695
return self._constructor(new_values, index=new_index).__finalize__(
46944696
self, method="to_period"

0 commit comments

Comments
 (0)