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

Index class ignores dtype parameter #235

Closed
CRP opened this issue Oct 14, 2011 · 6 comments
Closed

Index class ignores dtype parameter #235

CRP opened this issue Oct 14, 2011 · 6 comments

Comments

@CRP
Copy link
Contributor

CRP commented Oct 14, 2011

Apparently Index always forces dtype to object, irrespective of what is specified as parameter.

Pandas 0.4.3

@wesm
Copy link
Member

wesm commented Oct 14, 2011

This is intentional for now. The only two supported types are object and integer (int64) at the moment-- is it preventing you from doing something? You are actually the first person who's ever raised this as an issue.

@CRP
Copy link
Contributor Author

CRP commented Oct 14, 2011

Not really, just something I noticed while trying (unsuccessfully) to Index a dataframe with floats.

BTW, I just started using pandas a few days ago and love it, great job!

@wesm
Copy link
Member

wesm commented Oct 14, 2011

Ah, gotcha. Well they'll still be floats inside the object array and lookups will work and all that.

You know, it would be cool to make a Float64Index class- now that Int64Index has been done and integrated so it will play nice with object Indexes it should be largely a copy-paste job. I'll create a separate github issue about this and tag you in it

@lodagro
Copy link
Contributor

lodagro commented Mar 23, 2012

Somehow i was completely ignorant of the fact that there are only two supported types (object and int64) for an index.
This breaks my idea to use dtype of an index to check if it holds numeric data.

from pandas/core/index.py Index class

   def is_numeric(self):
        return issubclass(self.dtype.type, np.number)

The only place this little method is used is in Series.plot() and DataFrame.plot().
So what is an eficent way to check of the index holds numeric data? Fixing this will close #954

@adamklein
Copy link
Contributor

There is an inferred_type property that I'm using in the timeseries branch (b/c datetime64 is technically an int64), maybe can use this.

@wesm
Copy link
Member

wesm commented Mar 23, 2012

inferred_type is present in master and save to use for this case

In [1]: Index(randn(10)).inferred_type
Out[1]: 'floating'

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

4 participants