Skip to content
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

Printing a Series with dtype timedelta64 #2146

pag opened this issue Oct 30, 2012 · 0 comments


Copy link

commented Oct 30, 2012

>>> import pandas as pd
>>> import numpy as np
>>> print pd.Series(np.array([1100, 20], dtype='timedelta64[s]'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 911, in __str__
    return repr(self)
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 847, in __repr__
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 908, in _get_repr
    return formatter.to_string()
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 126, in to_string
    fmt_values = self._get_formatted_values()
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 117, in _get_formatted_values
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 691, in format_array
    return fmt_obj.get_result()
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 814, in get_result
    fmt_values = [formatter(x) for x in self.values]
  File "C:\Python27_64\lib\site-packages\pandas\core\", line 812, in <lambda>
    formatter = lambda x: '% d' % x
TypeError: %d format: a number is required, not numpy.timedelta64

This is because timedelta64 is an int type (see format.format_array) but can't be formatted like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.