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

Closed
pag opened this issue Oct 30, 2012 · 0 comments
Closed

Printing a Series with dtype timedelta64 #2146

pag opened this issue Oct 30, 2012 · 0 comments
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@pag
Copy link

pag 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\series.py", line 911, in __str__
    return repr(self)
  File "C:\Python27_64\lib\site-packages\pandas\core\series.py", line 847, in __repr__
    name=True)
  File "C:\Python27_64\lib\site-packages\pandas\core\series.py", line 908, in _get_repr
    return formatter.to_string()
  File "C:\Python27_64\lib\site-packages\pandas\core\format.py", line 126, in to_string
    fmt_values = self._get_formatted_values()
  File "C:\Python27_64\lib\site-packages\pandas\core\format.py", line 117, in _get_formatted_values
    na_rep=self.na_rep)
  File "C:\Python27_64\lib\site-packages\pandas\core\format.py", line 691, in format_array
    return fmt_obj.get_result()
  File "C:\Python27_64\lib\site-packages\pandas\core\format.py", line 814, in get_result
    fmt_values = [formatter(x) for x in self.values]
  File "C:\Python27_64\lib\site-packages\pandas\core\format.py", 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
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

2 participants