question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: User-facing AssertionError in Series.to_timestamp

See original GitHub issue
  • 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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
TomAugspurgercommented, Apr 6, 2020

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 assert for mypy after we’ve done the user-facing check if needed.

0reactions
simonjayhawkinscommented, May 20, 2020
  • I have confirmed this bug exists on the latest version of pandas.

the assertion was added in #31126 (i…e not yet released)

on 1.0.3

>>> import pandas as pd
>>>
>>> pd.__version__
'1.0.3'
>>>
>>> pd.Series([0]).to_timestamp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\pandas\pandas\core\series.py", line 4529, in to_timestamp
    new_index = self.index.to_timestamp(freq=freq, how=how)
AttributeError: 'RangeIndex' object has no attribute 'to_timestamp'
>>>
Read more comments on GitHub >

github_iconTop Results From Across the Web

BUG: pd.testing.assert_frame_equal(..., check_exact ... - GitHub
I have confirmed this bug exists on the latest version of pandas. ... AssertionError: check_exact may only be used with numeric Series ......
Read more >
AssertionError when converting a list to dataframe in pandas
I believe the most likely explanation is that the submissions returned from the query don't all have the same number of fields, ...
Read more >
What's New — pandas 0.23.3 documentation - PyData |
Bug in Timestamp and DatetimeIndex where passing a Timestamp localized after a DST transition would return a datetime ... New user-facing pandas.api.types.
Read more >
What's new — MNE 1.2.2 documentation
PSD plots will now show non-data channels (e.g., misc ) if those channels are explicitly passed to picks , by Daniel McCloy. Fix...
Read more >
SAML Login Errors - Salesforce Help
Use the login history to determine whether a login error is related to the SAML assertion or to your SSO configuration. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found