-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: User-facing AssertionError in Series.to_timestamp #33327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same issue applies to Series.to_period |
@TomAugspurger Are those assertions in order to placate mypy? Wonder if there's another way of doing that? |
Not sure. I would hope that with if not isinstance(self.index (ABCDatetimeIndex, ABCPeriodIndex)):
raise TypeError(...)
# hopefully mypy knows the types here but we can make the |
take |
Hello @CerseiO are you working on this or shall I work ? |
Hello @vipulrai91, not now, you can work on this. |
Thanks for confirming. |
take |
Does this work ? >>> pd.Series([0]).to_timestamp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/vipul/Work/Github/pandas/pandas/core/series.py", line 4665, in to_timestamp
raise TypeError(f"unsupported Type {self.index}")
TypeError: unsupported Type RangeIndex(start=0, stop=1, step=1) The code change made was: if not isinstance(self.index, (ABCDatetimeIndex, ABCPeriodIndex)):
raise TypeError(f"unsupported Type {self.index}")
new_index = self.index.to_timestamp(freq=freq, how=how)
return self._constructor(new_values, index=new_index).__finalize__(
self, method="to_timestamp") |
the assertion was added in #31126 (i..e not yet released) on 1.0.3
|
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
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
.The text was updated successfully, but these errors were encountered: