Support using DataFrame index for colors, labels, x, y, etc.
See original GitHub issueI often use the DataFrame index for something meaningful, such as a timestamp corresponding to when the data was taken, or a sequence number. In those cases, it’d be great to be able to use that in plotly express to determine the X value, data color, text label, etc.
Currently the workaround is to copy the index to a separate column, e.g.
# Contrived example, but this usually comes from some other system
df = pd.DataFrame({'y': [1,2,3]}, index=[4,5,6])
df['x'] = df.index
px.scatter(df, x=px.INDEX, y='y')
Instead of having to change the DataFrame, it would be nice if I could just go ahead and do something like
df = pd.DataFrame({'y': [1,2,3]}, index=[4,5,6])
px.scatter(df, x=px.INDEX, y='y')
or even, in the special case of using it as an X value, it could be the default:
px.scatter(df, y='y')
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Indexing and selecting data — pandas 1.5.2 documentation
pandas now supports three types of multi-axis indexing. .loc is primarily label based, but may also be used with a boolean array. .loc ......
Read more >Indexing and Selecting Data — pandas 0.13.1 documentation
A slice object with ints 1:7. See more at Selection by Position .ix supports mixed integer and label based access. It is primarily...
Read more >Indexing and Selecting Data — pandas 0.16.2 documentation
pandas now supports three types of multi-axis indexing. .loc is primarily label based, but may also be used with a boolean array. .loc...
Read more >Indexing and Selecting Data — pandas 0.15.2 documentation
A slice object with ints 1:7; A boolean array. See more at Selection by Position .ix supports mixed integer and label based access....
Read more >Table Visualization — pandas 1.5.2 documentation - PyData |
Styling should be performed after the data in a DataFrame has been processed. ... many parameters including colors, fonts, borders, background, etc.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This will be implemented as part of plotly/plotly.py#1767 … thanks for the input and patience 😃
We’ve actually gone farther and implemented full wide-mode support: https://medium.com/plotly/beyond-tidy-plotly-express-now-accepts-wide-form-and-mixed-form-data-bdc3e054f891