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

Fix chart exception where color-handling code expected DF index to start at 0 #8158

Merged
merged 2 commits into from Feb 15, 2024

Conversation

sfc-gh-tteixeira
Copy link
Contributor

Describe your changes

Fixes an exception in our native st.foo_chart commands, where color-handling code expected DF index to start at 0.

So, for example, the code below used to throw an exception:

        df = pd.DataFrame(
            {
                "a": [11, 2, 55],
                "b": [100, 101, 102],
                "c": [200, 201, 202],
                "d": [300, 301, 302],
            }
        )
        df.set_index("a", inplace=True)

        st.line_chart(df, x="b", y="c", color="d")

GitHub Issue Link (if applicable)

None.

Testing Plan

  • Explanation of why no additional tests are needed
  • Unit Tests (JS and/or Python)
  • E2E Tests
  • Any manual testing needed?
    • No

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Copy link
Collaborator

@LukasMasuch LukasMasuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 We recently had a community contribution to fix the same issue for st.map here: #8079 The PR used iloc, but I think iat is the better choice for this. It might be good to just update the iloc usage to iat in st.map as well.

@sfc-gh-tteixeira
Copy link
Contributor Author

Yeah, I saw the .iloc there but didn't want to touch it since it's working 😄

Did they contribute a test specifically for that bug in st.map? If so, I'll happily change to .iat right now

@sfc-gh-tteixeira
Copy link
Contributor Author

sfc-gh-tteixeira commented Feb 15, 2024

Oh, actually I do see tests. I'll change it to .iat, BRB

@sfc-gh-tteixeira
Copy link
Contributor Author

Done. PTAL

@LukasMasuch
Copy link
Collaborator

Perfect, looks great 👍 Merging it now (not sure if you have merging permission?)

@LukasMasuch LukasMasuch merged commit 4c97241 into streamlit:develop Feb 15, 2024
35 checks passed
@sfc-gh-tteixeira
Copy link
Contributor Author

Thanks!

I was just waiting for a final review 😉

zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
…art at 0 (streamlit#8158)

## Describe your changes

Fixes an exception in our native st.foo_chart commands, where
color-handling code expected DF index to start at 0.

So, for example, the code below used to throw an exception:

```python
        df = pd.DataFrame(
            {
                "a": [11, 2, 55],
                "b": [100, 101, 102],
                "c": [200, 201, 202],
                "d": [300, 301, 302],
            }
        )
        df.set_index("a", inplace=True)

        st.line_chart(df, x="b", y="c", color="d")
```

## GitHub Issue Link (if applicable)

None.

## Testing Plan

- ~~Explanation of why no additional tests are needed~~
- [x] Unit Tests (JS and/or Python)
- ~~E2E Tests~~
- Any manual testing needed?
  - **No**

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants