Skip to content

BUG: User-facing AssertionError in Series.to_timestamp #33327

Closed
@TomAugspurger

Description

@TomAugspurger
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


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)
<ipython-input-6-1a9d08d7daba> in <module>
----> 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions