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

MultiIndex promotes float64 dtype to object #3211

Closed
dalejung opened this issue Mar 29, 2013 · 4 comments
Closed

MultiIndex promotes float64 dtype to object #3211

dalejung opened this issue Mar 29, 2013 · 4 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@dalejung
Copy link
Contributor

import pandas as pd
import numpy as np
print pd.__version__
#0.11.0.dev-184f2db

lev1 = np.arange(10)
lev2 = np.linspace(0, 9, 10)
mi = pd.MultiIndex.from_arrays([lev1, lev2])

# ints work fine
assert lev1.dtype == mi.levels[0].dtype

# failure
assert lev2.dtype == mi.levels[1].dtype
print lev2.dtype, mi.levels[1].dtype
# float64 object

Ran into this when using np.isclose on the level values. Numpy fails due to casting rules and object dtype.

@dalejung
Copy link
Contributor Author

Ah, just noticed that this is more of an pd.Index thing.

#236

btw, how do you properly reference another issue?

@jreback
Copy link
Contributor

jreback commented Apr 1, 2013

this is correct behavior. have floats in an index is funny in any event w.r.t. indexing. do you have a particular situation that this is showing a problem in?

np.isclose requires a numeric dtype which is why that would fail (if comparing to a float dtype), which you know

@dalejung
Copy link
Contributor Author

dalejung commented Apr 1, 2013

I ran into the issue when running tests on parameter distributions created by something like np.linspace. The resulting DataFrame had the parameters in the columns and I was grabbing a subset to plot.

In either case, I adjusted for this behavior on my end. This can be closed if it's invalid.

@jreback
Copy link
Contributor

jreback commented Apr 1, 2013

thanks

@jreback jreback closed this as completed Apr 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

2 participants