question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support using DataFrame index for colors, labels, x, y, etc.

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, Sep 11, 2019

This will be implemented as part of plotly/plotly.py#1767 … thanks for the input and patience 😃

0reactions
nicolaskruchtencommented, May 26, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found