Skip to content

cut with np.inf gives TypeError #5483

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

Closed
DanielWeitzenfeld opened this issue Nov 10, 2013 · 2 comments
Closed

cut with np.inf gives TypeError #5483

DanielWeitzenfeld opened this issue Nov 10, 2013 · 2 comments

Comments

@DanielWeitzenfeld
Copy link

import pandas as pd
import numpy as np
arr = np.random.randn(20)
factor = pd.cut(arr, [-np.inf, 0, np.inf])

gives this error:

Traceback (most recent call last):
File "", line 1, in
File "/Users/weitzenfeld/anaconda/lib/python2.7/site-packages/pandas/tools/tile.py", line 102, in cut
include_lowest=include_lowest)
File "/Users/weitzenfeld/anaconda/lib/python2.7/site-packages/pandas/tools/tile.py", line 168, in _bins_to_cuts
include_lowest=include_lowest)
File "/Users/weitzenfeld/anaconda/lib/python2.7/site-packages/pandas/tools/tile.py", line 204, in _format_levels
fa, fb = fmt(a), fmt(b)
File "/Users/weitzenfeld/anaconda/lib/python2.7/site-packages/pandas/tools/tile.py", line 200, in
fmt = lambda v: _format_label(v, precision=prec)
File "/Users/weitzenfeld/anaconda/lib/python2.7/site-packages/pandas/tools/tile.py", line 247, in _format_label
return sgn + '%d' % whole
TypeError: %d format: a number is required, not numpy.float64

I'm using pandas version 0.12.0. Removing the -np.inf and np.inf eliminates the error.

@jreback
Copy link
Contributor

jreback commented Nov 10, 2013

iirc this works in master
can u give a try

@DanielWeitzenfeld
Copy link
Author

you're right, was fixed here:
166f907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants