BUG: User-facing AssertionError in Series.to_timestamp · Issue #33327 · pandas-dev/pandas (original) (raw)


Code Sample, a copy-pastable example

In [5]: import pandas as pd

In [6]: pd.Series([0]).to_timestamp()

AssertionError Traceback (most recent call last) in ----> 1 pd.Series([0]).to_timestamp()

~/sandbox/pandas/pandas/core/series.py in to_timestamp(self, freq, how, copy) 4565 new_values = new_values.copy() 4566 -> 4567 assert isinstance(self.index, (ABCDatetimeIndex, ABCPeriodIndex)) 4568 new_index = self.index.to_timestamp(freq=freq, how=how) 4569 return self._constructor(new_values, index=new_index).finalize(

AssertionError:

Problem description

Users shouldn't see AssertionErrors like this, since they may be disabled when the interpreter starts up.

Expected Output

We probably want this to be a TypeError.