posit-dev / posit-dev/py-shiny

Data frame fails when columns are integers

Open
#802 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

We should convert column names to character in the decorator.

from shiny import App, reactive, ui, render
import pandas as pd

df = pd.DataFrame({1: [1, 2, 3], 2: [4, 5, 6]})

app_ui = ui.page_fluid(ui.output_data_frame("char_df"), ui.output_data_frame("int_df"))


def server(input, output, session):
    @output
    @render.data_frame()
    def char_df():
        df2 = df.copy()
        df2.columns = df2.columns.astype(str)
        return df2

    @output
    @render.data_frame()
    def int_df():
        return df


app = App(app_ui, server, debug=False)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the render.data_frame decorator and reproduce the example using the integer-named pandas DataFrame. Compare it with the version whose columns are converted to strings; done means both data frames render successfully with equivalent column labels.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.