Skip to content

DataFrame.plot() does not treat float index as numeric #954

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
lodagro opened this issue Mar 22, 2012 · 0 comments
Closed

DataFrame.plot() does not treat float index as numeric #954

lodagro opened this issue Mar 22, 2012 · 0 comments

Comments

@lodagro
Copy link
Contributor

lodagro commented Mar 22, 2012

DataFrame.plot() does not treat float index as numeric.

This is becasue DataFrame.index.is_numeric() returns False when the index holds floats.
DataFrame.index.is_numeric() checks on the dtype of the index to know if it holds numeric data. Apparently dtype of a float index is object.

example from the mailing list

In [89]: df = pd.DataFrame(np.random.randn(4,3), columns=['A', 'B',
'C'])

In [90]: df
Out[90]:
         A         B         C
0 -1.209472 -2.016404  0.748993
1  0.568799  1.332006  1.228565
2 -1.105552  0.247344  0.379427
3  0.518771  1.155601  0.441952

In [91]: df.set_index('A')
Out[91]:
                 B         C
A
-1.209472 -2.016404  0.748993
 0.568799  1.332006  1.228565
-1.105552  0.247344  0.379427
 0.518771  1.155601  0.441952

In [93]: df2 = df.set_index('A')

In [98]: df2.plot()
Out[98]: <matplotlib.axes.AxesSubplot object at 0x5a942d0>

In [100]: xlim()
Out[100]: (0.0, 3.0)
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

1 participant